llvm.org GIT mirror llvm / 94b590f
ARM: allow vanilla expressions for movw/movt. Expressions for movw/movt don't always have an :upper16: or :lower16: on them and that's ok. When they don't, it's just a plain [0-65536] immediate result, effectively the same as a :lower16: variant kind. rdar://10550147 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155941 91177308-0d34-0410-b5e6-96231b3b80d8 Jim Grosbach 8 years ago
2 changed file(s) with 21 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
860860
861861 // Handle :upper16: and :lower16: assembly prefixes.
862862 const MCExpr *E = MO.getExpr();
863 MCFixupKind Kind;
863864 if (E->getKind() == MCExpr::Target) {
864865 const ARMMCExpr *ARM16Expr = cast(E);
865866 E = ARM16Expr->getSubExpr();
866867
867 MCFixupKind Kind;
868868 switch (ARM16Expr->getKind()) {
869869 default: llvm_unreachable("Unsupported ARMFixup");
870870 case ARMMCExpr::VK_ARM_HI16:
890890 }
891891 Fixups.push_back(MCFixup::Create(0, E, Kind, MI.getLoc()));
892892 return 0;
893 };
894
895 llvm_unreachable("Unsupported MCExpr type in MCOperand!");
893 }
894 // If the expression doesn't have :upper16: or :lower16: on it,
895 // it's just a plain immediate expression, and those evaluate to
896 // the lower 16 bits of the expression regardless of whether
897 // we have a movt or a movw.
898 if (!isTargetDarwin() && EvaluateAsPCRel(E))
899 Kind = MCFixupKind(isThumb2()
900 ? ARM::fixup_t2_movw_lo16_pcrel
901 : ARM::fixup_arm_movw_lo16_pcrel);
902 else
903 Kind = MCFixupKind(isThumb2()
904 ? ARM::fixup_t2_movw_lo16
905 : ARM::fixup_arm_movw_lo16);
906 Fixups.push_back(MCFixup::Create(0, E, Kind, MI.getLoc()));
907 return 0;
896908 }
897909
898910 uint32_t ARMMCCodeEmitter::
1414 @ CHECK: @ fixup A - offset: 0, value: _foo, kind: fixup_arm_movw_lo16
1515 @ CHECK: movt r9, :upper16:_foo @ encoding: [A,0x90'A',0b0100AAAA,0xe3]
1616 @ CHECK: @ fixup A - offset: 0, value: _foo, kind: fixup_arm_movt_hi16
17
18 mov r2, fred
19
20 @ CHECK: movw r2, fred @ encoding: [A,0x20'A',0b0000AAAA,0xe3]
21 @ CHECK: @ fixup A - offset: 0, value: fred, kind: fixup_arm_movw_lo16