[PATCH] D72275: [RISCV] Handle globals and block addresses in asm operands
Luís Marques via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 13 07:44:35 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG043c5eafa878: [RISCV] Handle globals and block addresses in asm operands (authored by luismarques).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72275/new/
https://reviews.llvm.org/D72275
Files:
llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
llvm/test/CodeGen/RISCV/inline-asm.ll
Index: llvm/test/CodeGen/RISCV/inline-asm.ll
===================================================================
--- llvm/test/CodeGen/RISCV/inline-asm.ll
+++ llvm/test/CodeGen/RISCV/inline-asm.ll
@@ -78,7 +78,7 @@
; RV64I-NEXT: lw a0, 0(a0)
; RV64I-NEXT: #NO_APP
; RV64I-NEXT: ret
- %1 = tail call i32 asm "lw $0, $1", "=r,*m"(i32* %a) nounwind
+ %1 = tail call i32 asm "lw $0, $1", "=r,*m"(i32* %a)
ret i32 %1
}
@@ -249,4 +249,46 @@
ret i32 %1
}
-; TODO: expend tests for more complex constraints, out of range immediates etc
+define void @operand_global() nounwind {
+; RV32I-LABEL: operand_global:
+; RV32I: # %bb.0:
+; RV32I-NEXT: #APP
+; RV32I-NEXT: .8byte gi
+; RV32I-NEXT: #NO_APP
+; RV32I-NEXT: ret
+;
+; RV64I-LABEL: operand_global:
+; RV64I: # %bb.0:
+; RV64I-NEXT: #APP
+; RV64I-NEXT: .8byte gi
+; RV64I-NEXT: #NO_APP
+; RV64I-NEXT: ret
+ tail call void asm sideeffect ".8byte $0", "i"(i32* @gi)
+ ret void
+}
+
+define void @operand_block_address() nounwind {
+; RV32I-LABEL: operand_block_address:
+; RV32I: # %bb.0:
+; RV32I-NEXT: #APP
+; RV32I-NEXT: j .Ltmp0
+; RV32I-NEXT: #NO_APP
+; RV32I-NEXT: .Ltmp0: # Block address taken
+; RV32I-NEXT: # %bb.1: # %bb
+; RV32I-NEXT: ret
+;
+; RV64I-LABEL: operand_block_address:
+; RV64I: # %bb.0:
+; RV64I-NEXT: #APP
+; RV64I-NEXT: j .Ltmp0
+; RV64I-NEXT: #NO_APP
+; RV64I-NEXT: .Ltmp0: # Block address taken
+; RV64I-NEXT: # %bb.1: # %bb
+; RV64I-NEXT: ret
+ call void asm sideeffect "j $0", "i"(i8* blockaddress(@operand_block_address, %bb))
+ br label %bb
+bb:
+ ret void
+}
+
+; TODO: expand tests for more complex constraints, out of range immediates etc
Index: llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
+++ llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
@@ -121,6 +121,14 @@
case MachineOperand::MO_Register:
OS << RISCVInstPrinter::getRegisterName(MO.getReg());
return false;
+ case MachineOperand::MO_GlobalAddress:
+ PrintSymbolOperand(MO, OS);
+ return false;
+ case MachineOperand::MO_BlockAddress: {
+ MCSymbol *Sym = GetBlockAddressSymbol(MO.getBlockAddress());
+ Sym->print(OS, MAI);
+ return false;
+ }
default:
break;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72275.237676.patch
Type: text/x-patch
Size: 2350 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200113/ea86c700/attachment.bin>
More information about the llvm-commits
mailing list