summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/ARM64/Disassembler/ARM64Disassembler.cpp
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2014-05-22 11:56:09 +0000
committerTim Northover <tnorthover@apple.com>2014-05-22 11:56:09 +0000
commitc350acfda59336e54a5dd4e139dd5c650e6a1968 (patch)
tree9d24215b1acda35d902d7113a1fe44c4ddc6d9f4 /llvm/lib/Target/ARM64/Disassembler/ARM64Disassembler.cpp
parent18b68e16af01f9493b25b12d654ac08794818eea (diff)
downloadbcm5719-llvm-c350acfda59336e54a5dd4e139dd5c650e6a1968.tar.gz
bcm5719-llvm-c350acfda59336e54a5dd4e139dd5c650e6a1968.zip
ARM64: separate load/store operands to simplify assembler
This changes ARM64 to use separate operands for each component of an address, and look for separate '[', '$Rn, ..., ']' tokens when parsing. This allows us to do away with quite a bit of special C++ code to handle monolithic "addressing modes" in the MC components. The more incremental matching of the assembler operands also allows for better diagnostics when LLVM is presented with invalid input. Most of the complexity here is with the register-offset instructions, which were extremely dodgy beforehand: even when the instruction used wM, LLVM's model had xM as an operand. We papered over this discrepancy before, but that approach doesn't work now so I split them into separate X and W variants. llvm-svn: 209425
Diffstat (limited to 'llvm/lib/Target/ARM64/Disassembler/ARM64Disassembler.cpp')
-rw-r--r--llvm/lib/Target/ARM64/Disassembler/ARM64Disassembler.cpp88
1 files changed, 9 insertions, 79 deletions
diff --git a/llvm/lib/Target/ARM64/Disassembler/ARM64Disassembler.cpp b/llvm/lib/Target/ARM64/Disassembler/ARM64Disassembler.cpp
index 92eabcf2b4e..20bcb366bf5 100644
--- a/llvm/lib/Target/ARM64/Disassembler/ARM64Disassembler.cpp
+++ b/llvm/lib/Target/ARM64/Disassembler/ARM64Disassembler.cpp
@@ -89,6 +89,8 @@ static DecodeStatus DecodeFixedPointScaleImm64(llvm::MCInst &Inst, unsigned Imm,
const void *Decoder);
static DecodeStatus DecodePCRelLabel19(llvm::MCInst &Inst, unsigned Imm,
uint64_t Address, const void *Decoder);
+static DecodeStatus DecodeMemExtend(llvm::MCInst &Inst, unsigned Imm,
+ uint64_t Address, const void *Decoder);
static DecodeStatus DecodeMRSSystemRegister(llvm::MCInst &Inst, unsigned Imm,
uint64_t Address, const void *Decoder);
static DecodeStatus DecodeMSRSystemRegister(llvm::MCInst &Inst, unsigned Imm,
@@ -114,10 +116,6 @@ static DecodeStatus DecodeExclusiveLdStInstruction(llvm::MCInst &Inst,
static DecodeStatus DecodePairLdStInstruction(llvm::MCInst &Inst, uint32_t insn,
uint64_t Address,
const void *Decoder);
-static DecodeStatus DecodeRegOffsetLdStInstruction(llvm::MCInst &Inst,
- uint32_t insn,
- uint64_t Address,
- const void *Decoder);
static DecodeStatus DecodeAddSubERegInstruction(llvm::MCInst &Inst,
uint32_t insn, uint64_t Address,
const void *Decoder);
@@ -605,6 +603,13 @@ static DecodeStatus DecodePCRelLabel19(llvm::MCInst &Inst, unsigned Imm,
return Success;
}
+static DecodeStatus DecodeMemExtend(llvm::MCInst &Inst, unsigned Imm,
+ uint64_t Address, const void *Decoder) {
+ Inst.addOperand(MCOperand::CreateImm((Imm >> 1) & 1));
+ Inst.addOperand(MCOperand::CreateImm(Imm & 1));
+ return Success;
+}
+
static DecodeStatus DecodeMRSSystemRegister(llvm::MCInst &Inst, unsigned Imm,
uint64_t Address,
const void *Decoder) {
@@ -1189,81 +1194,6 @@ static DecodeStatus DecodePairLdStInstruction(llvm::MCInst &Inst, uint32_t insn,
return Success;
}
-static DecodeStatus DecodeRegOffsetLdStInstruction(llvm::MCInst &Inst,
- uint32_t insn, uint64_t Addr,
- const void *Decoder) {
- unsigned Rt = fieldFromInstruction(insn, 0, 5);
- unsigned Rn = fieldFromInstruction(insn, 5, 5);
- unsigned Rm = fieldFromInstruction(insn, 16, 5);
- unsigned extendHi = fieldFromInstruction(insn, 13, 3);
- unsigned extendLo = fieldFromInstruction(insn, 12, 1);
- unsigned extend = (extendHi << 1) | extendLo;
-
- // All RO load-store instructions are undefined if option == 00x or 10x.
- if (extend >> 2 == 0x0 || extend >> 2 == 0x2)
- return Fail;
-
- switch (Inst.getOpcode()) {
- default:
- return Fail;
- case ARM64::LDRSWro:
- DecodeGPR64RegisterClass(Inst, Rt, Addr, Decoder);
- break;
- case ARM64::LDRXro:
- case ARM64::STRXro:
- DecodeGPR64RegisterClass(Inst, Rt, Addr, Decoder);
- break;
- case ARM64::LDRWro:
- case ARM64::STRWro:
- DecodeGPR32RegisterClass(Inst, Rt, Addr, Decoder);
- break;
- case ARM64::LDRQro:
- case ARM64::STRQro:
- DecodeFPR128RegisterClass(Inst, Rt, Addr, Decoder);
- break;
- case ARM64::LDRDro:
- case ARM64::STRDro:
- DecodeFPR64RegisterClass(Inst, Rt, Addr, Decoder);
- break;
- case ARM64::LDRSro:
- case ARM64::STRSro:
- DecodeFPR32RegisterClass(Inst, Rt, Addr, Decoder);
- break;
- case ARM64::LDRHro:
- case ARM64::STRHro:
- DecodeFPR16RegisterClass(Inst, Rt, Addr, Decoder);
- break;
- case ARM64::LDRBro:
- case ARM64::STRBro:
- DecodeFPR8RegisterClass(Inst, Rt, Addr, Decoder);
- break;
- case ARM64::LDRBBro:
- case ARM64::STRBBro:
- case ARM64::LDRSBWro:
- DecodeGPR32RegisterClass(Inst, Rt, Addr, Decoder);
- break;
- case ARM64::LDRHHro:
- case ARM64::STRHHro:
- case ARM64::LDRSHWro:
- DecodeGPR32RegisterClass(Inst, Rt, Addr, Decoder);
- break;
- case ARM64::LDRSHXro:
- DecodeGPR64RegisterClass(Inst, Rt, Addr, Decoder);
- break;
- case ARM64::LDRSBXro:
- DecodeGPR64RegisterClass(Inst, Rt, Addr, Decoder);
- break;
- case ARM64::PRFMro:
- Inst.addOperand(MCOperand::CreateImm(Rt));
- }
-
- DecodeGPR64spRegisterClass(Inst, Rn, Addr, Decoder);
- DecodeGPR64RegisterClass(Inst, Rm, Addr, Decoder);
-
- Inst.addOperand(MCOperand::CreateImm(extend));
- return Success;
-}
-
static DecodeStatus DecodeAddSubERegInstruction(llvm::MCInst &Inst,
uint32_t insn, uint64_t Addr,
const void *Decoder) {
OpenPOWER on IntegriCloud