summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/ARM64/InstPrinter/ARM64InstPrinter.cpp
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2014-05-01 12:29:38 +0000
committerTim Northover <tnorthover@apple.com>2014-05-01 12:29:38 +0000
commit534acbdf73449b060a3c8962bd2fc639f5352fdd (patch)
tree9425b79bcf37307dbb9b20419fa9057694800b68 /llvm/lib/Target/ARM64/InstPrinter/ARM64InstPrinter.cpp
parent7cc4ed8202fac742632dadfa067d3d8d2ba4302c (diff)
downloadbcm5719-llvm-534acbdf73449b060a3c8962bd2fc639f5352fdd.tar.gz
bcm5719-llvm-534acbdf73449b060a3c8962bd2fc639f5352fdd.zip
AArch64/ARM64: print BFM instructions as BFI or BFXIL
The canonical form of the BFM instruction is always one of the more explicit extract or insert operations, which makes reading output much easier. llvm-svn: 207752
Diffstat (limited to 'llvm/lib/Target/ARM64/InstPrinter/ARM64InstPrinter.cpp')
-rw-r--r--llvm/lib/Target/ARM64/InstPrinter/ARM64InstPrinter.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM64/InstPrinter/ARM64InstPrinter.cpp b/llvm/lib/Target/ARM64/InstPrinter/ARM64InstPrinter.cpp
index 8d217a9b394..a9ba7d277d4 100644
--- a/llvm/lib/Target/ARM64/InstPrinter/ARM64InstPrinter.cpp
+++ b/llvm/lib/Target/ARM64/InstPrinter/ARM64InstPrinter.cpp
@@ -171,6 +171,33 @@ void ARM64InstPrinter::printInst(const MCInst *MI, raw_ostream &O,
return;
}
+ if (Opcode == ARM64::BFMXri || Opcode == ARM64::BFMWri) {
+ const MCOperand &Op0 = MI->getOperand(0); // Op1 == Op0
+ const MCOperand &Op2 = MI->getOperand(2);
+ int ImmR = MI->getOperand(3).getImm();
+ int ImmS = MI->getOperand(4).getImm();
+
+ // BFI alias
+ if (ImmS < ImmR) {
+ int BitWidth = Opcode == ARM64::BFMXri ? 64 : 32;
+ int LSB = (BitWidth - ImmR) % BitWidth;
+ int Width = ImmS + 1;
+ O << "\tbfi\t" << getRegisterName(Op0.getReg()) << ", "
+ << getRegisterName(Op2.getReg()) << ", #" << LSB << ", #" << Width;
+ printAnnotation(O, Annot);
+ return;
+ }
+
+ int LSB = ImmR;
+ int Width = ImmS - ImmR + 1;
+ // Otherwise BFXIL the prefered form
+ O << "\tbfxil\t"
+ << getRegisterName(Op0.getReg()) << ", " << getRegisterName(Op2.getReg())
+ << ", #" << LSB << ", #" << Width;
+ printAnnotation(O, Annot);
+ return;
+ }
+
// Symbolic operands for MOVZ, MOVN and MOVK already imply a shift
// (e.g. :gottprel_g1: is always going to be "lsl #16") so it should not be
// printed.
OpenPOWER on IntegriCloud