summaryrefslogtreecommitdiffstats
path: root/llvm/test/MC/RISCV/function-call-invalid.s
diff options
context:
space:
mode:
authorShiva Chen <shiva0217@gmail.com>2018-04-25 14:18:55 +0000
committerShiva Chen <shiva0217@gmail.com>2018-04-25 14:18:55 +0000
commit98f9389f65e630a7243f9c99717009107758d492 (patch)
tree5f26acce6a9bb1ea9db630f0ba78a41a9ad3fac2 /llvm/test/MC/RISCV/function-call-invalid.s
parent0f2f5976d07f4cfc312f2f2485e982551d6d6cf1 (diff)
downloadbcm5719-llvm-98f9389f65e630a7243f9c99717009107758d492.tar.gz
bcm5719-llvm-98f9389f65e630a7243f9c99717009107758d492.zip
[RISCV] Support "call" pseudoinstruction in the MC layer
To do this: 1. Add PseudoCALLIndirct to match indirect function call. 2. Add PseudoCALL to support parsing and print pseudo `call` in assembly 3. Expand PseudoCALL to the following form with R_RISCV_CALL relocation type while encoding: auipc ra, func jalr ra, ra, 0 If we expand PseudoCALL before emitting assembly, we will see auipc and jalr pair when compile with -S. It's hard for assembly parser to parsing this pair and identify it's semantic is function call and then insert R_RISCV_CALL relocation type. Although we could insert R_RISCV_PCREL_HI20 and R_RISCV_PCREL_LO12_I relocation types instead of R_RISCV_CALL. Due to RISCV relocation design, auipc and jalr pair only can relax to jal with R_RISCV_CALL + R_RISCV_RELAX relocation types. We expand PseudoCALL as late as encoding(RISCVMCCodeEmitter) instead of before emitting assembly(RISCVAsmPrinter) because we want to preserve call pseudoinstruction in assembly code. It's more readable and assembly parser could identify call assembly and insert R_RISCV_CALL relocation type. Differential Revision: https://reviews.llvm.org/D45859 llvm-svn: 330826
Diffstat (limited to 'llvm/test/MC/RISCV/function-call-invalid.s')
-rw-r--r--llvm/test/MC/RISCV/function-call-invalid.s11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/test/MC/RISCV/function-call-invalid.s b/llvm/test/MC/RISCV/function-call-invalid.s
new file mode 100644
index 00000000000..14532495e3f
--- /dev/null
+++ b/llvm/test/MC/RISCV/function-call-invalid.s
@@ -0,0 +1,11 @@
+# RUN: not llvm-mc -triple riscv32 < %s 2>&1 | FileCheck %s
+
+call 1234 # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
+call %pcrel_hi(1234) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
+call %pcrel_lo(1234) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
+call %pcrel_hi(foo) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
+call %pcrel_lo(foo) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
+call %hi(1234) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
+call %lo(1234) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
+call %hi(foo) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
+call %lo(foo) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
OpenPOWER on IntegriCloud