llvm.org GIT mirror llvm / a8e47b3
store MC FP immediates as a double instead of as an APFloat, thus avoiding an unnecessary dtor for MCOperand. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114064 91177308-0d34-0410-b5e6-96231b3b80d8 Jim Grosbach 9 years ago
4 changed file(s) with 12 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
1515 #ifndef LLVM_MC_MCINST_H
1616 #define LLVM_MC_MCINST_H
1717
18 #include "llvm/ADT/APFloat.h"
1918 #include "llvm/ADT/SmallVector.h"
2019 #include "llvm/ADT/StringRef.h"
2120 #include "llvm/System/DataTypes.h"
4140 union {
4241 unsigned RegVal;
4342 int64_t ImmVal;
43 double FPImmVal;
4444 const MCExpr *ExprVal;
4545 };
46 // This can't go in the union due to the non-trivial copy constructor
47 // of APFloat. It's still only valid for Kind == kFPImmediate, though.
48 APFloat FPImmVal;
4946 public:
5047
5148 MCOperand() : Kind(kInvalid), FPImmVal(0.0) {}
7774 ImmVal = Val;
7875 }
7976
80 const APFloat &getFPImm() const {
77 const double &getFPImm() const {
8178 assert(isFPImm() && "This is not an FP immediate");
8279 return FPImmVal;
8380 }
8481
85 void setFPImm(const APFloat &Val) {
82 void setFPImm(double Val) {
8683 assert(isFPImm() && "This is not an FP immediate");
8784 FPImmVal = Val;
8885 }
108105 Op.ImmVal = Val;
109106 return Op;
110107 }
111 static MCOperand CreateFPImm(const APFloat &Val) {
108 static MCOperand CreateFPImm(double Val) {
112109 MCOperand Op;
113110 Op.Kind = kFPImmediate;
114111 Op.FPImmVal = Val;
156156 MO.getBlockAddress()));
157157 break;
158158 case MachineOperand::MO_FPImmediate:
159 MCOp = MCOperand::CreateFPImm(MO.getFPImm()->getValueAPF());
159 MCOp =
160 MCOperand::CreateFPImm(MO.getFPImm()->getValueAPF().convertToDouble());
160161 break;
161162 }
162163
746746
747747 void ARMInstPrinter::printVFPf32ImmOperand(const MCInst *MI, unsigned OpNum,
748748 raw_ostream &O) {
749 O << '#' << MI->getOperand(OpNum).getFPImm().convertToFloat();
749 O << '#' << (float)MI->getOperand(OpNum).getFPImm();
750750 }
751751
752752 void ARMInstPrinter::printVFPf64ImmOperand(const MCInst *MI, unsigned OpNum,
753753 raw_ostream &O) {
754 O << '#' << MI->getOperand(OpNum).getFPImm().convertToDouble();
754 O << '#' << MI->getOperand(OpNum).getFPImm();
755755 }
756756
757757 void ARMInstPrinter::printNEONModImmOperand(const MCInst *MI, unsigned OpNum,
19721972 // The asm syntax specifies the floating point value, not the 8-bit literal.
19731973 APInt immRaw = VFPExpandImm(slice(insn,19,16) << 4 | slice(insn, 3, 0),
19741974 Opcode == ARM::FCONSTD ? 64 : 32);
1975 MI.addOperand(MCOperand::CreateFPImm(APFloat(immRaw, true)));
1975 APFloat immFP = APFloat(immRaw, true);
1976 double imm = Opcode == ARM::FCONSTD ? immFP.convertToDouble() :
1977 immFP.convertToFloat();
1978 MI.addOperand(MCOperand::CreateFPImm(imm));
19761979
19771980 ++OpIdx;
19781981 }