Skip to content

Commit

Permalink
Add --n64align flag (#12)
Browse files Browse the repository at this point in the history
* --n64align

* Rename to `--force-n64align`

* Add `pull_request` to CI
  • Loading branch information
AngheloAlf authored Jan 21, 2024
1 parent 0655d8f commit 54514de
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Build

on: [push]
on: [push, pull_request]

jobs:
build:
Expand Down
9 changes: 8 additions & 1 deletion gas/as.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ Options:\n\
--statistics print maximum bytes and total seconds used\n\
--version print assembler version number and exit\n\
-V, --vr4300mul-off turn off vr4300 mulmul fix\n\
-N, --force-n64align enable special alignment for Nintendo 64\n\
-W suppress warnings\n\
-w ignored\n\
-X ignored\n\
Expand Down Expand Up @@ -219,6 +220,7 @@ common_emul_init ()
*/

extern int vr4300mul_enabled;
extern int force_n64align_enabled;

void
parse_args (pargc, pargv)
Expand All @@ -242,7 +244,7 @@ parse_args (pargc, pargv)
/* -K is not meaningful if .word is not being hacked. */
'K',
#endif
'L', 'M', 'R', 'W', 'Z', 'f', 'a', ':', ':', 'D', 'I', ':', 'o', ':',
'L', 'M', 'R', 'W', 'Z', 'f', 'a', 'V', 'N', ':', ':', 'D', 'I', ':', 'o', ':',
#ifndef VMS
/* -v takes an argument on VMS, so we don't make it a generic
option. */
Expand All @@ -259,6 +261,7 @@ parse_args (pargc, pargv)
{"help", no_argument, NULL, OPTION_HELP},
{"mri", no_argument, NULL, 'M'},
{"vr4300mul-off", no_argument, NULL, 'V'},
{"force-n64align", no_argument, NULL, 'N'},
#define OPTION_NOCPP (OPTION_STD_BASE + 1)
{"nocpp", no_argument, NULL, OPTION_NOCPP},
#define OPTION_STATISTICS (OPTION_STD_BASE + 2)
Expand Down Expand Up @@ -494,6 +497,10 @@ parse_args (pargc, pargv)
vr4300mul_enabled = 0;
break;

case 'N':
force_n64align_enabled = 1;
break;

case 'w':
break;

Expand Down
43 changes: 26 additions & 17 deletions gas/config/obj-elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ elf_file_symbol (s)
}
}

int force_n64align_enabled = 0;

static void
obj_elf_common (ignore)
int ignore;
Expand Down Expand Up @@ -275,25 +277,32 @@ obj_elf_common (ignore)
}
}
if (size < 0x400)
{
if (size < 0x10)
{
n64_extra_align = 0;
}
else
{
n64_extra_align = 8;
}
}
{
if (size < 0x10)
{
n64_extra_align = 0;
}
else
{
n64_extra_align = 8;
}
}
else
{
n64_extra_align = 16;
}
{
n64_extra_align = 16;
}
if (temp < n64_extra_align)
{
as_warn("Variable %s would be aligned in KMC GCC (has %d, would have %d)",
S_GET_NAME (symbolP), temp, n64_extra_align);
}
{
if (force_n64align_enabled)
{
temp = n64_extra_align;
}
else
{
as_warn("Variable %s would be aligned in KMC GCC (has %d, would have %d)",
S_GET_NAME (symbolP), temp, n64_extra_align);
}
}
if (symbolP->local)
{
segT old_sec;
Expand Down

0 comments on commit 54514de

Please sign in to comment.