-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[RISCV] Support .option {no}exact #122483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 16 commits
8d8ed46
eba37b2
f6b0186
546f52c
3d9113d
dece4a6
c70f679
4e2aaee
b832095
32f3944
8133e9d
3fc5749
c8bf695
7dc2322
61bdfeb
2c62a5b
318afee
58a0f1b
a764474
859b430
6c10814
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # RUN: llvm-mc -triple riscv32 -show-encoding -mattr=+c %s \ | ||
| # RUN: | FileCheck -check-prefixes=CHECK,CHECK-ALIAS %s | ||
| # RUN: llvm-mc -triple riscv32 -show-encoding -mattr=+c \ | ||
| # RUN: -M no-aliases %s | FileCheck -check-prefixes=CHECK,CHECK-INST %s | ||
| # RUN: llvm-mc -triple riscv32 -filetype=obj -mattr=+c %s \ | ||
| # RUN: | llvm-objdump --triple=riscv32 --mattr=+c --no-print-imm-hex -d - \ | ||
| # RUN: | FileCheck -check-prefixes=CHECK-BYTES,CHECK-ALIAS %s | ||
| # RUN: llvm-mc -triple riscv32 -filetype=obj -mattr=+c %s \ | ||
| # RUN: | llvm-objdump --triple=riscv32 --mattr=+c --no-print-imm-hex -d -M no-aliases - \ | ||
|
||
| # RUN: | FileCheck -check-prefixes=CHECK-BYTES,CHECK-INST %s | ||
|
|
||
| # RUN: llvm-mc -triple riscv64 -show-encoding -mattr=+c %s \ | ||
| # RUN: | FileCheck -check-prefixes=CHECK-ALIAS %s | ||
| # RUN: llvm-mc -triple riscv64 -show-encoding -mattr=+c \ | ||
| # RUN: -M no-aliases %s | FileCheck -check-prefixes=CHECK-INST %s | ||
| # RUN: llvm-mc -triple riscv64 -filetype=obj -mattr=+c %s \ | ||
| # RUN: | llvm-objdump --triple=riscv64 --mattr=+c --no-print-imm-hex -d - \ | ||
| # RUN: | FileCheck -check-prefixes=CHECK-BYTES,CHECK-ALIAS %s | ||
| # RUN: llvm-mc -triple riscv64 -filetype=obj -mattr=+c %s \ | ||
| # RUN: | llvm-objdump --triple=riscv64 --mattr=+c --no-print-imm-hex -d -M no-aliases - \ | ||
| # RUN: | FileCheck -check-prefixes=CHECK-BYTES,CHECK-INST %s | ||
|
|
||
|
|
||
| ## `.option exact` disables a variety of assembler behaviour: | ||
| ## - automatic compression | ||
| ## - branch relaxation (of short branches to longer equivalent sequences) | ||
| ## - linker relaxation (emitting R_RISCV_RELAX) | ||
| ## `.option noexact` enables these behaviours again. It is also the default. | ||
|
|
||
| ## This test only checks the automatic compression part of this behaviour. | ||
|
|
||
| # CHECK-BYTES: 4108 | ||
| # CHECK-INST: c.lw a0, 0(a0) | ||
| # CHECK-ALIAS: lw a0, 0(a0) | ||
| # CHECK: # encoding: [0x08,0x41] | ||
| lw a0, 0(a0) | ||
|
|
||
| # CHECK-BYTES: 4108 | ||
| # CHECK-INST: c.lw a0, 0(a0) | ||
| # CHECK-ALIAS: lw a0, 0(a0) | ||
| # CHECK: # encoding: [0x08,0x41] | ||
| c.lw a0, 0(a0) | ||
|
|
||
| # CHECK: .option exact | ||
| .option exact | ||
|
|
||
| # CHECK-BYTES: 00052503 | ||
| # CHECK-INST: lw a0, 0(a0) | ||
| # CHECK-ALIAS: lw a0, 0(a0) | ||
| # CHECK: # encoding: [0x03,0x25,0x05,0x00] | ||
| lw a0, 0(a0) | ||
|
|
||
| # CHECK-BYTES: 4108 | ||
| # CHECK-INST: c.lw a0, 0(a0) | ||
| # CHECK-ALIAS: lw a0, 0(a0) | ||
| # CHECK: # encoding: [0x08,0x41] | ||
| c.lw a0, 0(a0) | ||
|
|
||
| # CHECK: .option noexact | ||
| .option noexact | ||
|
|
||
| # CHECK-BYTES: 4108 | ||
| # CHECK-INST: c.lw a0, 0(a0) | ||
| # CHECK-ALIAS: lw a0, 0(a0) | ||
| # CHECK: # encoding: [0x08,0x41] | ||
| lw a0, 0(a0) | ||
|
|
||
| # CHECK-BYTES: 4108 | ||
| # CHECK-INST: c.lw a0, 0(a0) | ||
| # CHECK-ALIAS: lw a0, 0(a0) | ||
| # CHECK: # encoding: [0x08,0x41] | ||
| c.lw a0, 0(a0) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| ; RUN: llc -mtriple=riscv32 -mattr=+relax,+c %s --filetype=obj -o - \ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move to test/CodeGen/RISCV?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, yeah, this location was a little iffy, happier to have an |
||
| ; RUN: | llvm-objdump --triple=riscv32 --mattr=+c -M no-aliases -dr - \ | ||
| ; RUN: | FileCheck %s | ||
|
|
||
| define i32 @foo(ptr noundef %f) nounwind { | ||
| ; CHECK-LABEL: <foo>: | ||
| ; CHECK: auipc ra, 0x0 | ||
| ; CHECK-NEXT: R_RISCV_CALL_PLT undefined | ||
| ; CHECK-NEXT: jalr ra, 0x0(ra) | ||
| ; CHECK-NEXT: lw a0, 0x0(a0) | ||
| ; CHECK-NEXT: c.jr ra | ||
|
|
||
| entry: | ||
| %0 = tail call i32 asm sideeffect " | ||
| .option exact | ||
| call undefined@plt | ||
| lw $0, ($1) | ||
| .option noexact", "=^cr,^cr"(ptr %f) | ||
| ret i32 %0 | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.