llvm.org GIT mirror llvm / a9a5c53
Mips specific inline asm operand modifier 'D' Modifier 'D' is to use the second word of a double integer. We had previously implemented the pure register varient of the modifier and this patch implements the memory reference. #include "stdio.h" int b[8] = {0,1,2,3,4,5,6,7}; void main() { int i; // The first word. Notice, no 'D' {asm ( "lw %0,%1;" : "=r" (i) : "m" (*(b+4)) );} printf("%d\n",i); // The second word {asm ( "lw %0,%D1;" : "=r" (i) : "m" (*(b+4)) );} printf("%d\n",i); } git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179135 91177308-0d34-0410-b5e6-96231b3b80d8 Jack Carter 7 years ago
2 changed file(s) with 26 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
422422 unsigned OpNum, unsigned AsmVariant,
423423 const char *ExtraCode,
424424 raw_ostream &O) {
425 if (ExtraCode && ExtraCode[0])
426 return true; // Unknown modifier.
425 int Offset = 0;
426 // Currently we are expecting either no ExtraCode or 'D'
427 if (ExtraCode) {
428 if (ExtraCode[0] == 'D')
429 Offset = 4;
430 else
431 return true; // Unknown modifier.
432 }
427433
428434 const MachineOperand &MO = MI->getOperand(OpNum);
429435 assert(MO.isReg() && "unexpected inline asm memory operand");
430 O << "0($" << MipsInstPrinter::getRegisterName(MO.getReg()) << ")";
436 O << Offset << "($" << MipsInstPrinter::getRegisterName(MO.getReg()) << ")";
431437
432438 return false;
433439 }
0 ; RUN: llc -march=mipsel < %s | FileCheck %s
11
2 ; Simple memory
23 @g1 = external global i32
34
45 define i32 @f1(i32 %x) nounwind {
2021 ret i32 %0
2122 }
2223
24 ; "D": Second word of double word. This works for any memory element.
25 ; CHECK: #APP
26 ; CHECK-NEXT: lw ${{[0-9]+}},4(${{[0-9]+}});
27 ; CHECK-NEXT: #NO_APP
28
29 @b = common global [20 x i32] zeroinitializer, align 4
30
31 define void @main() #0 {
32 entry:
33 tail call void asm sideeffect " lw $0,${1:D};", "r,*m,~{$11}"(i32 undef, i32* getelementptr inbounds ([20 x i32]* @b, i32 0, i32 3)) #1
34 ret void
35 }
36
37 attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
38 attributes #1 = { nounwind }
39