[llvm-commits] [llvm] r95767 - in /llvm/trunk: include/llvm/MC/MCFixup.h lib/MC/MCAsmStreamer.cpp lib/Target/X86/X86CodeEmitter.cpp
Daniel Dunbar
daniel at zuster.org
Tue Feb 9 20:47:08 PST 2010
Author: ddunbar
Date: Tue Feb 9 22:47:08 2010
New Revision: 95767
URL: http://llvm.org/viewvc/llvm-project?rev=95767&view=rev
Log:
MC: Switch MCFixup to just hold an MCExpr pointer instead of index into the
MCInst it came from.
Modified:
llvm/trunk/include/llvm/MC/MCFixup.h
llvm/trunk/lib/MC/MCAsmStreamer.cpp
llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp
Modified: llvm/trunk/include/llvm/MC/MCFixup.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCFixup.h?rev=95767&r1=95766&r2=95767&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCFixup.h (original)
+++ llvm/trunk/include/llvm/MC/MCFixup.h Tue Feb 9 22:47:08 2010
@@ -13,6 +13,7 @@
#include <cassert>
namespace llvm {
+class MCExpr;
// Private constants, do not use.
//
@@ -25,10 +26,8 @@
// end up needing more bits for target dependent kinds.
enum {
MCFIXUP_NUM_GENERIC_KINDS = 128,
- MCFIXUP_NUM_KIND_BITS = 8,
- MCFIXUP_NUM_OPINDEX_BITS = 8,
- MCFIXUP_NUM_OFFSET_BITS = (32 - MCFIXUP_NUM_OPINDEX_BITS -
- MCFIXUP_NUM_OPINDEX_BITS)
+ MCFIXUP_NUM_KIND_BITS = 16,
+ MCFIXUP_NUM_OFFSET_BITS = (32 - MCFIXUP_NUM_KIND_BITS)
};
/// MCFixupKind - Extensible enumeration to represent the type of a fixup.
@@ -60,34 +59,36 @@
class MCFixup {
static const unsigned MaxOffset = 1 << MCFIXUP_NUM_KIND_BITS;
+ /// The value to put into the fixup location. The exact interpretation of the
+ /// expression is target dependent, usually it will one of the operands to an
+ /// instruction or an assembler directive.
+ const MCExpr *Value;
+
/// The byte index of start of the relocation inside the encoded instruction.
unsigned Offset : MCFIXUP_NUM_OFFSET_BITS;
- /// The index of the operand to encode into the instruction.
- unsigned OpIndex : MCFIXUP_NUM_OPINDEX_BITS;
-
/// The target dependent kind of fixup item this is. The kind is used to
/// determine how the operand value should be encoded into the instruction.
unsigned Kind : MCFIXUP_NUM_KIND_BITS;
public:
- static MCFixup Create(unsigned Offset, unsigned OpIndex, MCFixupKind Kind) {
+ static MCFixup Create(unsigned Offset, const MCExpr *Value,
+ MCFixupKind Kind) {
MCFixup FI;
+ FI.Value = Value;
FI.Offset = Offset;
- FI.OpIndex = OpIndex;
FI.Kind = unsigned(Kind);
assert(Offset == FI.getOffset() && "Offset out of range!");
- assert(OpIndex == FI.getOpIndex() && "Operand index out of range!");
assert(Kind == FI.getKind() && "Kind out of range!");
return FI;
}
- unsigned getOffset() const { return Offset; }
+ MCFixupKind getKind() const { return MCFixupKind(Kind); }
- unsigned getOpIndex() const { return OpIndex; }
+ unsigned getOffset() const { return Offset; }
- MCFixupKind getKind() const { return MCFixupKind(Kind); }
+ const MCExpr *getValue() const { return Value; }
};
} // End llvm namespace
Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=95767&r1=95766&r2=95767&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Tue Feb 9 22:47:08 2010
@@ -601,7 +601,7 @@
MCFixup &F = Fixups[i];
MCFixupKindInfo &Info = Emitter->getFixupKindInfo(F.getKind());
OS << " fixup " << char('A' + i) << " - " << "offset: " << F.getOffset()
- << ", op: " << F.getOpIndex() << ", kind: " << Info.Name << "\n";
+ << ", value: " << *F.getValue() << ", kind: " << Info.Name << "\n";
}
}
Modified: llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp?rev=95767&r1=95766&r2=95767&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp Tue Feb 9 22:47:08 2010
@@ -878,12 +878,14 @@
namespace {
class MCSingleInstructionCodeEmitter : public MachineCodeEmitter {
uint8_t Data[256];
+ const MCInst *CurrentInst;
SmallVectorImpl<MCFixup> *FixupList;
public:
- MCSingleInstructionCodeEmitter() { reset(0); }
+ MCSingleInstructionCodeEmitter() { reset(0, 0); }
- void reset(SmallVectorImpl<MCFixup> *Fixups) {
+ void reset(const MCInst *Inst, SmallVectorImpl<MCFixup> *Fixups) {
+ CurrentInst = Inst;
FixupList = Fixups;
BufferBegin = Data;
BufferEnd = array_endof(Data);
@@ -915,7 +917,9 @@
OpIndex = MR.getJumpTableIndex();
}
- FixupList->push_back(MCFixup::Create(Offset, OpIndex,
+ MCOperand Op = CurrentInst->getOperand(OpIndex);
+ assert(Op.isExpr() && "FIXME: Not yet implemented!");
+ FixupList->push_back(MCFixup::Create(Offset, Op.getExpr(),
MCFixupKind(FirstTargetFixupKind + Kind)));
}
virtual void setModuleInfo(MachineModuleInfo* Info) {}
@@ -1163,7 +1167,7 @@
Instr->dump();
}
- InstrEmitter->reset(&Fixups);
+ InstrEmitter->reset(&MI, &Fixups);
if (OK)
Emit->emitInstruction(*Instr, &Desc);
OS << InstrEmitter->str();
More information about the llvm-commits
mailing list