diff options
| author | David Woodhouse <dwmw2@infradead.org> | 2014-01-28 23:13:18 +0000 | 
|---|---|---|
| committer | David Woodhouse <dwmw2@infradead.org> | 2014-01-28 23:13:18 +0000 | 
| commit | 3fa98a65e978b01f2cc7486ad1fbd15442b6c1ef (patch) | |
| tree | bd6d413605cba4c756b12a163855068fbc7ea271 /llvm/lib/Target/SystemZ/MCTargetDesc | |
| parent | 9784cef38dd71ae37ccc419d7e1e10bafe59e9df (diff) | |
| download | bcm5719-llvm-3fa98a65e978b01f2cc7486ad1fbd15442b6c1ef.tar.gz bcm5719-llvm-3fa98a65e978b01f2cc7486ad1fbd15442b6c1ef.zip  | |
Propagate MCSubtargetInfo through TableGen's getBinaryCodeForInstr()
llvm-svn: 200349
Diffstat (limited to 'llvm/lib/Target/SystemZ/MCTargetDesc')
| -rw-r--r-- | llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCCodeEmitter.cpp | 73 | 
1 files changed, 44 insertions, 29 deletions
diff --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCCodeEmitter.cpp b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCCodeEmitter.cpp index d7ac2379dcb..84dc47300ca 100644 --- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCCodeEmitter.cpp +++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCCodeEmitter.cpp @@ -42,27 +42,34 @@ public:  private:    // Automatically generated by TableGen.    uint64_t getBinaryCodeForInstr(const MCInst &MI, -                                 SmallVectorImpl<MCFixup> &Fixups) const; +                                 SmallVectorImpl<MCFixup> &Fixups, +                                 const MCSubtargetInfo &STI) const;    // Called by the TableGen code to get the binary encoding of operand    // MO in MI.  Fixups is the list of fixups against MI.    uint64_t getMachineOpValue(const MCInst &MI, const MCOperand &MO, -                             SmallVectorImpl<MCFixup> &Fixups) const; +                             SmallVectorImpl<MCFixup> &Fixups, +                             const MCSubtargetInfo &STI) const;    // Called by the TableGen code to get the binary encoding of an address.    // The index or length, if any, is encoded first, followed by the base,    // followed by the displacement.  In a 20-bit displacement,    // the low 12 bits are encoded before the high 8 bits.    uint64_t getBDAddr12Encoding(const MCInst &MI, unsigned OpNum, -                               SmallVectorImpl<MCFixup> &Fixups) const; +                               SmallVectorImpl<MCFixup> &Fixups, +                               const MCSubtargetInfo &STI) const;    uint64_t getBDAddr20Encoding(const MCInst &MI, unsigned OpNum, -                               SmallVectorImpl<MCFixup> &Fixups) const; +                               SmallVectorImpl<MCFixup> &Fixups, +                               const MCSubtargetInfo &STI) const;    uint64_t getBDXAddr12Encoding(const MCInst &MI, unsigned OpNum, -                                SmallVectorImpl<MCFixup> &Fixups) const; +                                SmallVectorImpl<MCFixup> &Fixups, +                                const MCSubtargetInfo &STI) const;    uint64_t getBDXAddr20Encoding(const MCInst &MI, unsigned OpNum, -                                SmallVectorImpl<MCFixup> &Fixups) const; +                                SmallVectorImpl<MCFixup> &Fixups, +                                const MCSubtargetInfo &STI) const;    uint64_t getBDLAddr12Len8Encoding(const MCInst &MI, unsigned OpNum, -                                    SmallVectorImpl<MCFixup> &Fixups) const; +                                    SmallVectorImpl<MCFixup> &Fixups, +                                    const MCSubtargetInfo &STI) const;    // Operand OpNum of MI needs a PC-relative fixup of kind Kind at    // Offset bytes from the start of MI.  Add the fixup to Fixups @@ -73,11 +80,13 @@ private:                              unsigned Kind, int64_t Offset) const;    uint64_t getPC16DBLEncoding(const MCInst &MI, unsigned OpNum, -                              SmallVectorImpl<MCFixup> &Fixups) const { +                              SmallVectorImpl<MCFixup> &Fixups, +                              const MCSubtargetInfo &STI) const {      return getPCRelEncoding(MI, OpNum, Fixups, SystemZ::FK_390_PC16DBL, 2);    }    uint64_t getPC32DBLEncoding(const MCInst &MI, unsigned OpNum, -                              SmallVectorImpl<MCFixup> &Fixups) const { +                              SmallVectorImpl<MCFixup> &Fixups, +                              const MCSubtargetInfo &STI) const {      return getPCRelEncoding(MI, OpNum, Fixups, SystemZ::FK_390_PC32DBL, 2);    }  }; @@ -94,7 +103,7 @@ void SystemZMCCodeEmitter::  EncodeInstruction(const MCInst &MI, raw_ostream &OS,                    SmallVectorImpl<MCFixup> &Fixups,                    const MCSubtargetInfo &STI) const { -  uint64_t Bits = getBinaryCodeForInstr(MI, Fixups); +  uint64_t Bits = getBinaryCodeForInstr(MI, Fixups, STI);    unsigned Size = MCII.get(MI.getOpcode()).getSize();    // Big-endian insertion of Size bytes.    unsigned ShiftValue = (Size * 8) - 8; @@ -106,7 +115,8 @@ EncodeInstruction(const MCInst &MI, raw_ostream &OS,  uint64_t SystemZMCCodeEmitter::  getMachineOpValue(const MCInst &MI, const MCOperand &MO, -                  SmallVectorImpl<MCFixup> &Fixups) const { +                  SmallVectorImpl<MCFixup> &Fixups, +                  const MCSubtargetInfo &STI) const {    if (MO.isReg())      return Ctx.getRegisterInfo()->getEncodingValue(MO.getReg());    if (MO.isImm()) @@ -116,38 +126,42 @@ getMachineOpValue(const MCInst &MI, const MCOperand &MO,  uint64_t SystemZMCCodeEmitter::  getBDAddr12Encoding(const MCInst &MI, unsigned OpNum, -                    SmallVectorImpl<MCFixup> &Fixups) const { -  uint64_t Base = getMachineOpValue(MI, MI.getOperand(OpNum), Fixups); -  uint64_t Disp = getMachineOpValue(MI, MI.getOperand(OpNum + 1), Fixups); +                    SmallVectorImpl<MCFixup> &Fixups, +                    const MCSubtargetInfo &STI) const { +  uint64_t Base = getMachineOpValue(MI, MI.getOperand(OpNum), Fixups, STI); +  uint64_t Disp = getMachineOpValue(MI, MI.getOperand(OpNum + 1), Fixups, STI);    assert(isUInt<4>(Base) && isUInt<12>(Disp));    return (Base << 12) | Disp;  }  uint64_t SystemZMCCodeEmitter::  getBDAddr20Encoding(const MCInst &MI, unsigned OpNum, -                    SmallVectorImpl<MCFixup> &Fixups) const { -  uint64_t Base = getMachineOpValue(MI, MI.getOperand(OpNum), Fixups); -  uint64_t Disp = getMachineOpValue(MI, MI.getOperand(OpNum + 1), Fixups); +                    SmallVectorImpl<MCFixup> &Fixups, +                    const MCSubtargetInfo &STI) const { +  uint64_t Base = getMachineOpValue(MI, MI.getOperand(OpNum), Fixups, STI); +  uint64_t Disp = getMachineOpValue(MI, MI.getOperand(OpNum + 1), Fixups, STI);    assert(isUInt<4>(Base) && isInt<20>(Disp));    return (Base << 20) | ((Disp & 0xfff) << 8) | ((Disp & 0xff000) >> 12);  }  uint64_t SystemZMCCodeEmitter::  getBDXAddr12Encoding(const MCInst &MI, unsigned OpNum, -                     SmallVectorImpl<MCFixup> &Fixups) const { -  uint64_t Base = getMachineOpValue(MI, MI.getOperand(OpNum), Fixups); -  uint64_t Disp = getMachineOpValue(MI, MI.getOperand(OpNum + 1), Fixups); -  uint64_t Index = getMachineOpValue(MI, MI.getOperand(OpNum + 2), Fixups); +                     SmallVectorImpl<MCFixup> &Fixups, +                     const MCSubtargetInfo &STI) const { +  uint64_t Base = getMachineOpValue(MI, MI.getOperand(OpNum), Fixups, STI); +  uint64_t Disp = getMachineOpValue(MI, MI.getOperand(OpNum + 1), Fixups, STI); +  uint64_t Index = getMachineOpValue(MI, MI.getOperand(OpNum + 2), Fixups, STI);    assert(isUInt<4>(Base) && isUInt<12>(Disp) && isUInt<4>(Index));    return (Index << 16) | (Base << 12) | Disp;  }  uint64_t SystemZMCCodeEmitter::  getBDXAddr20Encoding(const MCInst &MI, unsigned OpNum, -                     SmallVectorImpl<MCFixup> &Fixups) const { -  uint64_t Base = getMachineOpValue(MI, MI.getOperand(OpNum), Fixups); -  uint64_t Disp = getMachineOpValue(MI, MI.getOperand(OpNum + 1), Fixups); -  uint64_t Index = getMachineOpValue(MI, MI.getOperand(OpNum + 2), Fixups); +                     SmallVectorImpl<MCFixup> &Fixups, +                     const MCSubtargetInfo &STI) const { +  uint64_t Base = getMachineOpValue(MI, MI.getOperand(OpNum), Fixups, STI); +  uint64_t Disp = getMachineOpValue(MI, MI.getOperand(OpNum + 1), Fixups, STI); +  uint64_t Index = getMachineOpValue(MI, MI.getOperand(OpNum + 2), Fixups, STI);    assert(isUInt<4>(Base) && isInt<20>(Disp) && isUInt<4>(Index));    return (Index << 24) | (Base << 20) | ((Disp & 0xfff) << 8)      | ((Disp & 0xff000) >> 12); @@ -155,10 +169,11 @@ getBDXAddr20Encoding(const MCInst &MI, unsigned OpNum,  uint64_t SystemZMCCodeEmitter::  getBDLAddr12Len8Encoding(const MCInst &MI, unsigned OpNum, -                         SmallVectorImpl<MCFixup> &Fixups) const { -  uint64_t Base = getMachineOpValue(MI, MI.getOperand(OpNum), Fixups); -  uint64_t Disp = getMachineOpValue(MI, MI.getOperand(OpNum + 1), Fixups); -  uint64_t Len  = getMachineOpValue(MI, MI.getOperand(OpNum + 2), Fixups) - 1; +                         SmallVectorImpl<MCFixup> &Fixups, +                         const MCSubtargetInfo &STI) const { +  uint64_t Base = getMachineOpValue(MI, MI.getOperand(OpNum), Fixups, STI); +  uint64_t Disp = getMachineOpValue(MI, MI.getOperand(OpNum + 1), Fixups, STI); +  uint64_t Len  = getMachineOpValue(MI, MI.getOperand(OpNum + 2), Fixups, STI) - 1;    assert(isUInt<4>(Base) && isUInt<12>(Disp) && isUInt<8>(Len));    return (Len << 16) | (Base << 12) | Disp;  }  | 

