Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,20 @@ jobs:
./scripts/autogen ${{ matrix.simplify.arg }}
make clean
OPT=1 make quickcheck
x86_64_intel_syntax:
name: x86_64 Intel syntax
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Generate with Intel syntax and test
uses: ./.github/actions/setup-shell
with:
nix-shell: 'ci'
gh_token: ${{ secrets.GITHUB_TOKEN }}
script: |
./scripts/autogen --x86-64-syntax intel
make clean
./scripts/tests all
scan-build:
strategy:
fail-fast: false
Expand Down
23 changes: 21 additions & 2 deletions scripts/autogen
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,7 @@ def update_via_simpasm(
preserve_header=True,
dry_run=False,
force_cross=False,
x86_64_syntax="att",
):
status_update("simpasm", infile_full)

Expand Down Expand Up @@ -1432,6 +1433,9 @@ def update_via_simpasm(
cmd += [f'--cflags="{cflags}"']
if preserve_header is True:
cmd += ["-p"]
# Add syntax option for x86_64
if arch == "x86_64" and x86_64_syntax != "att":
cmd += ["--syntax", x86_64_syntax]
r = subprocess.run(
cmd,
stdout=subprocess.DEVNULL,
Expand Down Expand Up @@ -1542,7 +1546,13 @@ def synchronize_backend(


def synchronize_backends(
*, dry_run=False, force_cross=False, clean=False, delete=False, no_simplify=False
*,
dry_run=False,
force_cross=False,
clean=False,
delete=False,
no_simplify=False,
x86_64_syntax="att",
):
if clean is False:
ty = "opt"
Expand Down Expand Up @@ -1603,6 +1613,7 @@ def synchronize_backends(
delete=delete,
force_cross=force_cross,
no_simplify=no_simplify,
x86_64_syntax=x86_64_syntax,
# Turn off control-flow protection (CET) explicitly. Newer versions of
# clang turn it on by default and insert endbr64 instructions at every
# global symbol.
Expand Down Expand Up @@ -2226,7 +2237,13 @@ def _main():
parser.add_argument("--aarch64-clean", default=True, action="store_true")
parser.add_argument("--no-simplify", default=False, action="store_true")
parser.add_argument("--force-cross", default=False, action="store_true")

parser.add_argument(
"--x86-64-syntax",
type=str,
choices=["att", "intel"],
default="att",
help="Assembly syntax for x86_64 disassembly output (att or intel)",
)
args = parser.parse_args()

os.chdir(os.path.join(os.path.dirname(__file__), ".."))
Expand All @@ -2248,6 +2265,7 @@ def _main():
clean=args.aarch64_clean,
no_simplify=args.no_simplify,
force_cross=args.force_cross,
x86_64_syntax=args.x86_64_syntax,
)
high_level_status("Synchronized backends")

Expand All @@ -2264,6 +2282,7 @@ def _main():
delete=True,
force_cross=args.force_cross,
no_simplify=args.no_simplify,
x86_64_syntax=args.x86_64_syntax,
)
high_level_status("Completed final backend synchronization")
gen_test_configs(args.dry_run)
Expand Down
4 changes: 2 additions & 2 deletions scripts/cfify
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ def add_cfi_directives(text, arch):
i += 1
continue

# x86_64: retq -> .cfi_endproc after retq
match = re.match(r"(\s*)retq\s*$", line, re.IGNORECASE)
# x86_64: ret/retq -> .cfi_endproc after ret
match = re.match(r"(\s*)retq?\s*$", line, re.IGNORECASE)
if match:
indent = match.group(1)
result.append(line)
Expand Down
16 changes: 16 additions & 0 deletions scripts/simpasm
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ def simplify(logger, args, asm_input, asm_output=None):
if platform.system() == "Darwin":
cmd += ["--triple=aarch64"]

# Add syntax option if specified
if args.syntax and args.syntax.lower() != "att":
cmd += [f"--x86-asm-syntax={args.syntax}"]

logger.debug(f"Disassembling temporary object file {tmp_objfile0} ...")
disasm = run_cmd(cmd).stdout

Expand All @@ -268,6 +272,10 @@ def simplify(logger, args, asm_input, asm_output=None):
".balign 4",
]

# Add syntax specifier for Intel syntax
if args.syntax and args.syntax.lower() == "intel":
autogen_header.append(".intel_syntax noprefix")

if args.preserve_preprocessor_directives is False:
if platform.system() == "Darwin" and sym[0] == "_":
sym = sym[1:]
Expand Down Expand Up @@ -414,6 +422,14 @@ def _main():
help="Target architecture for CFI directives",
)

parser.add_argument(
"--syntax",
type=str,
choices=["att", "intel"],
default="att",
help="Assembly syntax for disassembly output (att or intel)",
)

args = parser.parse_args()

os.chdir(os.path.join(os.path.dirname(__file__), ".."))
Expand Down