diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-06-30 01:49:52 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-06-30 01:49:52 +0000 |
commit | 15d170709608e2f1efcada74c297c10c8c71fdcf (patch) | |
tree | fb8cb7f88ebf927bad158feab87b50974bbafacb /include | |
parent | 9b27622ecb00a4e4b23fe501d11f344c7b9ba7ed (diff) | |
download | llvm-15d170709608e2f1efcada74c297c10c8c71fdcf.tar.gz llvm-15d170709608e2f1efcada74c297c10c8c71fdcf.tar.bz2 llvm-15d170709608e2f1efcada74c297c10c8c71fdcf.tar.xz |
llvm-mc: Evaluation for relocatable expressions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74496 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/MC/MCSymbol.h | 2 | ||||
-rw-r--r-- | include/llvm/MC/MCValue.h | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/include/llvm/MC/MCSymbol.h b/include/llvm/MC/MCSymbol.h index fcfc9d64e2..5f87f09694 100644 --- a/include/llvm/MC/MCSymbol.h +++ b/include/llvm/MC/MCSymbol.h @@ -13,6 +13,8 @@ #include <string> namespace llvm { + class MCSection; + class MCSymbol { MCSection *Section; std::string Name; diff --git a/include/llvm/MC/MCValue.h b/include/llvm/MC/MCValue.h index 811d331edd..df834c7de5 100644 --- a/include/llvm/MC/MCValue.h +++ b/include/llvm/MC/MCValue.h @@ -15,6 +15,8 @@ #define LLVM_MC_MCVALUE_H #include "llvm/Support/DataTypes.h" +#include "llvm/MC/MCSymbol.h" +#include <cassert> namespace llvm { class MCSymbol; @@ -23,6 +25,9 @@ class MCSymbol; /// form, this can hold "SymbolA - SymbolB + imm64". Not all targets supports /// relocations of this general form, but we need to represent this anyway. /// +/// In the general form, SymbolB can only be defined if SymbolA is, and both +/// must be in the same (non-external) section. +/// /// Note that this class must remain a simple POD value class, because we need /// it to live in unions etc. class MCValue { @@ -35,9 +40,21 @@ public: MCSymbol *getSymB() const { return SymB; } bool isConstant() const { return !SymA && !SymB; } - + + /// getAssociatedSection - For relocatable values, return the section the + /// value is associated with. + /// + /// @result - The value's associated section, or null for external or constant + /// values. + MCSection *getAssociatedSection() const { + return SymA ? SymA->getSection() : 0; + } + static MCValue get(MCSymbol *SymA, MCSymbol *SymB = 0, int64_t Val = 0) { MCValue R; + assert((!SymB || (SymA && SymA->getSection() && + SymA->getSection() == SymB->getSection())) && + "Invalid relocatable MCValue!"); R.Cst = Val; R.SymA = SymA; R.SymB = SymB; |