assert(OffsetMO.isImm() && "Unexpected offset for inline asm memory operand.");
int Offset = OffsetMO.getImm();
- // Currently we are expecting either no ExtraCode or 'D'
+ // Currently we are expecting either no ExtraCode or 'D','M','L'.
if (ExtraCode) {
- if (ExtraCode[0] == 'D')
+ switch (ExtraCode[0]) {
+ case 'D':
Offset += 4;
- else
+ break;
+ case 'M':
+ if (Subtarget->isLittle())
+ Offset += 4;
+ break;
+ case 'L':
+ if (!Subtarget->isLittle())
+ Offset += 4;
+ break;
+ default:
return true; // Unknown modifier.
- // FIXME: M = high order bits
- // FIXME: L = low order bits
+ }
}
- O << Offset << "($" << MipsInstPrinter::getRegisterName(BaseMO.getReg()) << ")";
+ O << Offset << "($" << MipsInstPrinter::getRegisterName(BaseMO.getReg())
+ << ")";
return false;
}
-; RUN: llc -march=mipsel -relocation-model=pic < %s | FileCheck %s
+; RUN: llc -march=mips -relocation-model=pic < %s \
+; RUN: | FileCheck --check-prefixes=CHECK,EB %s
+; RUN: llc -march=mipsel -relocation-model=pic < %s \
+; RUN: | FileCheck --check-prefixes=CHECK,EL %s
; Simple memory
@g1 = external global i32
; CHECK: lw ${{[0-9]+}}, 12(${{[0-9]+}})
; CHECK: #NO_APP
+; "M": High-order word of a double word.
+; CHECK: #APP
+; EB: lw ${{[0-9]+}}, 12(${{[0-9]+}})
+; EL: lw ${{[0-9]+}}, 16(${{[0-9]+}})
+; CHECK: #NO_APP
+
+; "L": Low-order word of a double word.
+; CHECK: #APP
+; EB: lw ${{[0-9]+}}, 16(${{[0-9]+}})
+; EL: lw ${{[0-9]+}}, 12(${{[0-9]+}})
+; CHECK: #NO_APP
+
@b = common global [20 x i32] zeroinitializer, align 4
define void @main() {
tail call void asm sideeffect " lw $0, ${1:D}", "r,*m,~{$11}"(i32 undef, i32* getelementptr inbounds ([20 x i32], [20 x i32]* @b, i32 0, i32 3))
; First word. Notice, no 'D':
tail call void asm sideeffect " lw $0, ${1}", "r,*m,~{$11}"(i32 undef, i32* getelementptr inbounds ([20 x i32], [20 x i32]* @b, i32 0, i32 3))
+
+; High-order part.
+ tail call void asm sideeffect " lw $0, ${1:M}", "r,*m,~{$11}"(i32 undef, i32* getelementptr inbounds ([20 x i32], [20 x i32]* @b, i32 0, i32 3))
+; Low-order part.
+ tail call void asm sideeffect " lw $0, ${1:L}", "r,*m,~{$11}"(i32 undef, i32* getelementptr inbounds ([20 x i32], [20 x i32]* @b, i32 0, i32 3))
ret void
}