diff options
author | Jim Grosbach <grosbach@apple.com> | 2012-01-26 23:20:11 +0000 |
---|---|---|
committer | Jim Grosbach <grosbach@apple.com> | 2012-01-26 23:20:11 +0000 |
commit | 82f4ce5081fc9cfbf34bbe61eb0412e7ca4dc3df (patch) | |
tree | f2f2b3b4edb43f23ad81386d77fe0252ebe1c881 /include | |
parent | 93cd59aea87a8f40f033d705cbbbfb7ab27b048f (diff) | |
download | external_llvm-82f4ce5081fc9cfbf34bbe61eb0412e7ca4dc3df.zip external_llvm-82f4ce5081fc9cfbf34bbe61eb0412e7ca4dc3df.tar.gz external_llvm-82f4ce5081fc9cfbf34bbe61eb0412e7ca4dc3df.tar.bz2 |
Add simple support for keeping MCFixup source information.
Can be used to issue more user friendly diagnostics for faulty
relocation constructs and such.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149092 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/MC/MCContext.h | 7 | ||||
-rw-r--r-- | include/llvm/MC/MCFixup.h | 8 | ||||
-rw-r--r-- | include/llvm/MC/MCInst.h | 6 |
3 files changed, 19 insertions, 2 deletions
diff --git a/include/llvm/MC/MCContext.h b/include/llvm/MC/MCContext.h index a1da8c5..8b4e296 100644 --- a/include/llvm/MC/MCContext.h +++ b/include/llvm/MC/MCContext.h @@ -15,6 +15,8 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/StringMap.h" #include "llvm/Support/Allocator.h" +#include "llvm/Support/Compiler.h" +#include "llvm/Support/SMLoc.h" #include "llvm/Support/raw_ostream.h" #include <vector> // FIXME: Shouldn't be needed. @@ -319,6 +321,11 @@ namespace llvm { } void Deallocate(void *Ptr) { } + + // Unrecoverable error has occured. Display the best diagnostic we can + // and bail via exit(1). For now, most MC backend errors are unrecoverable. + // FIXME: We should really do something about that. + LLVM_ATTRIBUTE_NORETURN void FatalError(SMLoc L, const Twine &Msg); }; } // end namespace llvm diff --git a/include/llvm/MC/MCFixup.h b/include/llvm/MC/MCFixup.h index 4aa361b..aaf5fe1 100644 --- a/include/llvm/MC/MCFixup.h +++ b/include/llvm/MC/MCFixup.h @@ -11,6 +11,7 @@ #define LLVM_MC_MCFIXUP_H #include "llvm/Support/DataTypes.h" +#include "llvm/Support/SMLoc.h" #include <cassert> namespace llvm { @@ -69,14 +70,17 @@ class MCFixup { /// determine how the operand value should be encoded into the instruction. unsigned Kind; + /// The source location which gave rise to the fixup, if any. + SMLoc Loc; public: static MCFixup Create(uint32_t Offset, const MCExpr *Value, - MCFixupKind Kind) { + MCFixupKind Kind, SMLoc Loc = SMLoc()) { assert(unsigned(Kind) < MaxTargetFixupKind && "Kind out of range!"); MCFixup FI; FI.Value = Value; FI.Offset = Offset; FI.Kind = unsigned(Kind); + FI.Loc = Loc; return FI; } @@ -98,6 +102,8 @@ public: case 8: return isPCRel ? FK_PCRel_8 : FK_Data_8; } } + + SMLoc getLoc() const { return Loc; } }; } // End llvm namespace diff --git a/include/llvm/MC/MCInst.h b/include/llvm/MC/MCInst.h index a2ade57..397a37d 100644 --- a/include/llvm/MC/MCInst.h +++ b/include/llvm/MC/MCInst.h @@ -19,6 +19,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/DataTypes.h" +#include "llvm/Support/SMLoc.h" namespace llvm { class raw_ostream; @@ -148,14 +149,17 @@ template <> struct isPodLike<MCOperand> { static const bool value = true; }; /// instruction. class MCInst { unsigned Opcode; + SMLoc Loc; SmallVector<MCOperand, 8> Operands; public: MCInst() : Opcode(0) {} void setOpcode(unsigned Op) { Opcode = Op; } - unsigned getOpcode() const { return Opcode; } + void setLoc(SMLoc loc) { Loc = loc; } + SMLoc getLoc() const { return Loc; } + const MCOperand &getOperand(unsigned i) const { return Operands[i]; } MCOperand &getOperand(unsigned i) { return Operands[i]; } unsigned getNumOperands() const { return Operands.size(); } |