diff --git a/lib/Target/ARM64/ARM64InstrFormats.td b/lib/Target/ARM64/ARM64InstrFormats.td index abb92514a5b..94fc2e0ab9f 100644 --- a/lib/Target/ARM64/ARM64InstrFormats.td +++ b/lib/Target/ARM64/ARM64InstrFormats.td @@ -277,6 +277,15 @@ def movz_symbol_g0 : Operand { let ParserMatchClass = MovZSymbolG0AsmOperand; } +def MovKSymbolG3AsmOperand : AsmOperandClass { + let Name = "MovKSymbolG3"; + let RenderMethod = "addImmOperands"; +} + +def movk_symbol_g3 : Operand { + let ParserMatchClass = MovKSymbolG3AsmOperand; +} + def MovKSymbolG2AsmOperand : AsmOperandClass { let Name = "MovKSymbolG2"; let RenderMethod = "addImmOperands"; diff --git a/lib/Target/ARM64/ARM64InstrInfo.td b/lib/Target/ARM64/ARM64InstrInfo.td index ab129cb46a5..e4b47d7355d 100644 --- a/lib/Target/ARM64/ARM64InstrInfo.td +++ b/lib/Target/ARM64/ARM64InstrInfo.td @@ -383,6 +383,7 @@ def : InstAlias<"movz $Rd, $sym", (MOVZWi GPR32:$Rd, movz_symbol_g2:$sym, 32)>; def : InstAlias<"movz $Rd, $sym", (MOVZWi GPR32:$Rd, movz_symbol_g1:$sym, 16)>; def : InstAlias<"movz $Rd, $sym", (MOVZWi GPR32:$Rd, movz_symbol_g0:$sym, 0)>; +def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movk_symbol_g3:$sym, 48)>; def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movk_symbol_g2:$sym, 32)>; def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movk_symbol_g1:$sym, 16)>; def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movk_symbol_g0:$sym, 0)>; diff --git a/lib/Target/ARM64/AsmParser/ARM64AsmParser.cpp b/lib/Target/ARM64/AsmParser/ARM64AsmParser.cpp index 7efc4572bda..f9d3c8b898a 100644 --- a/lib/Target/ARM64/AsmParser/ARM64AsmParser.cpp +++ b/lib/Target/ARM64/AsmParser/ARM64AsmParser.cpp @@ -610,6 +610,7 @@ public: bool isMovZSymbolG2() const { static ARM64MCExpr::VariantKind Variants[] = { ARM64MCExpr::VK_ABS_G2, + ARM64MCExpr::VK_ABS_G2_S, ARM64MCExpr::VK_TPREL_G2, ARM64MCExpr::VK_DTPREL_G2 }; return isMovWSymbol(Variants); @@ -617,6 +618,7 @@ public: bool isMovZSymbolG1() const { static ARM64MCExpr::VariantKind Variants[] = { ARM64MCExpr::VK_ABS_G1, + ARM64MCExpr::VK_ABS_G1_S, ARM64MCExpr::VK_GOTTPREL_G1, ARM64MCExpr::VK_TPREL_G1, ARM64MCExpr::VK_DTPREL_G1, }; @@ -625,11 +627,17 @@ public: bool isMovZSymbolG0() const { static ARM64MCExpr::VariantKind Variants[] = { ARM64MCExpr::VK_ABS_G0, + ARM64MCExpr::VK_ABS_G0_S, ARM64MCExpr::VK_TPREL_G0, ARM64MCExpr::VK_DTPREL_G0 }; return isMovWSymbol(Variants); } + bool isMovKSymbolG3() const { + static ARM64MCExpr::VariantKind Variants[] = { ARM64MCExpr::VK_ABS_G3 }; + return isMovWSymbol(Variants); + } + bool isMovKSymbolG2() const { static ARM64MCExpr::VariantKind Variants[] = { ARM64MCExpr::VK_ABS_G2_NC }; return isMovWSymbol(Variants); @@ -2985,10 +2993,13 @@ bool ARM64AsmParser::parseSymbolicImmVal(const MCExpr *&ImmVal) { .Case("lo12", ARM64MCExpr::VK_LO12) .Case("abs_g3", ARM64MCExpr::VK_ABS_G3) .Case("abs_g2", ARM64MCExpr::VK_ABS_G2) + .Case("abs_g2_s", ARM64MCExpr::VK_ABS_G2_S) .Case("abs_g2_nc", ARM64MCExpr::VK_ABS_G2_NC) .Case("abs_g1", ARM64MCExpr::VK_ABS_G1) + .Case("abs_g1_s", ARM64MCExpr::VK_ABS_G1_S) .Case("abs_g1_nc", ARM64MCExpr::VK_ABS_G1_NC) .Case("abs_g0", ARM64MCExpr::VK_ABS_G0) + .Case("abs_g0_s", ARM64MCExpr::VK_ABS_G0_S) .Case("abs_g0_nc", ARM64MCExpr::VK_ABS_G0_NC) .Case("dtprel_g2", ARM64MCExpr::VK_DTPREL_G2) .Case("dtprel_g1", ARM64MCExpr::VK_DTPREL_G1) diff --git a/lib/Target/ARM64/MCTargetDesc/ARM64ELFObjectWriter.cpp b/lib/Target/ARM64/MCTargetDesc/ARM64ELFObjectWriter.cpp index 718501f918e..d73188d4f0b 100644 --- a/lib/Target/ARM64/MCTargetDesc/ARM64ELFObjectWriter.cpp +++ b/lib/Target/ARM64/MCTargetDesc/ARM64ELFObjectWriter.cpp @@ -188,14 +188,20 @@ unsigned ARM64ELFObjectWriter::GetRelocType(const MCValue &Target, return ELF::R_AARCH64_MOVW_UABS_G3; if (RefKind == ARM64MCExpr::VK_ABS_G2) return ELF::R_AARCH64_MOVW_UABS_G2; + if (RefKind == ARM64MCExpr::VK_ABS_G2_S) + return ELF::R_AARCH64_MOVW_SABS_G2; if (RefKind == ARM64MCExpr::VK_ABS_G2_NC) return ELF::R_AARCH64_MOVW_UABS_G2_NC; if (RefKind == ARM64MCExpr::VK_ABS_G1) return ELF::R_AARCH64_MOVW_UABS_G1; + if (RefKind == ARM64MCExpr::VK_ABS_G1_S) + return ELF::R_AARCH64_MOVW_SABS_G1; if (RefKind == ARM64MCExpr::VK_ABS_G1_NC) return ELF::R_AARCH64_MOVW_UABS_G1_NC; if (RefKind == ARM64MCExpr::VK_ABS_G0) return ELF::R_AARCH64_MOVW_UABS_G0; + if (RefKind == ARM64MCExpr::VK_ABS_G0_S) + return ELF::R_AARCH64_MOVW_SABS_G0; if (RefKind == ARM64MCExpr::VK_ABS_G0_NC) return ELF::R_AARCH64_MOVW_UABS_G0_NC; if (RefKind == ARM64MCExpr::VK_DTPREL_G2) diff --git a/lib/Target/ARM64/MCTargetDesc/ARM64MCExpr.cpp b/lib/Target/ARM64/MCTargetDesc/ARM64MCExpr.cpp index 6de8a0699a2..c772002846c 100644 --- a/lib/Target/ARM64/MCTargetDesc/ARM64MCExpr.cpp +++ b/lib/Target/ARM64/MCTargetDesc/ARM64MCExpr.cpp @@ -36,10 +36,13 @@ StringRef ARM64MCExpr::getVariantKindName() const { case VK_LO12: return ":lo12:"; case VK_ABS_G3: return ":abs_g3:"; case VK_ABS_G2: return ":abs_g2:"; + case VK_ABS_G2_S: return ":abs_g2_s:"; case VK_ABS_G2_NC: return ":abs_g2_nc:"; case VK_ABS_G1: return ":abs_g1:"; + case VK_ABS_G1_S: return ":abs_g1_s:"; case VK_ABS_G1_NC: return ":abs_g1_nc:"; case VK_ABS_G0: return ":abs_g0:"; + case VK_ABS_G0_S: return ":abs_g0_s:"; case VK_ABS_G0_NC: return ":abs_g0_nc:"; case VK_DTPREL_G2: return ":dtprel_g2:"; case VK_DTPREL_G1: return ":dtprel_g1:"; diff --git a/lib/Target/ARM64/MCTargetDesc/ARM64MCExpr.h b/lib/Target/ARM64/MCTargetDesc/ARM64MCExpr.h index a33fe43b71c..cbff6e814df 100644 --- a/lib/Target/ARM64/MCTargetDesc/ARM64MCExpr.h +++ b/lib/Target/ARM64/MCTargetDesc/ARM64MCExpr.h @@ -63,10 +63,13 @@ public: VK_ABS_PAGE = VK_ABS | VK_PAGE, VK_ABS_G3 = VK_ABS | VK_G3, VK_ABS_G2 = VK_ABS | VK_G2, + VK_ABS_G2_S = VK_SABS | VK_G2, VK_ABS_G2_NC = VK_ABS | VK_G2 | VK_NC, VK_ABS_G1 = VK_ABS | VK_G1, + VK_ABS_G1_S = VK_SABS | VK_G1, VK_ABS_G1_NC = VK_ABS | VK_G1 | VK_NC, VK_ABS_G0 = VK_ABS | VK_G0, + VK_ABS_G0_S = VK_SABS | VK_G0, VK_ABS_G0_NC = VK_ABS | VK_G0 | VK_NC, VK_LO12 = VK_ABS | VK_PAGEOFF | VK_NC, VK_GOT_LO12 = VK_GOT | VK_PAGEOFF | VK_NC, diff --git a/test/MC/AArch64/elf-reloc-movw.s b/test/MC/AArch64/elf-reloc-movw.s index 333159562c0..29f89443c33 100644 --- a/test/MC/AArch64/elf-reloc-movw.s +++ b/test/MC/AArch64/elf-reloc-movw.s @@ -1,4 +1,7 @@ // RUN: llvm-mc -triple=aarch64-none-linux-gnu -filetype=obj %s -o - | \ +// RUN: llvm-readobj -r | FileCheck -check-prefix=OBJ %s + +// RUN: llvm-mc -triple=arm64-none-linux-gnu -filetype=obj %s -o - | \ // RUN: llvm-readobj -r | FileCheck -check-prefix=OBJ %s movz x0, #:abs_g0:some_label