1//===-- llvm/MC/MCValue.h - MCValue class -----------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file contains the declaration of the MCValue class. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LLVM_MC_MCVALUE_H 15#define LLVM_MC_MCVALUE_H 16 17#include "llvm/Support/DataTypes.h"
| 1//===-- llvm/MC/MCValue.h - MCValue class -----------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file contains the declaration of the MCValue class. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LLVM_MC_MCVALUE_H 15#define LLVM_MC_MCVALUE_H 16 17#include "llvm/Support/DataTypes.h"
|
| 18#include "llvm/MC/MCSymbol.h" 19#include <cassert>
|
18 19namespace llvm { 20class MCSymbol; 21 22/// MCValue - This represents an "assembler immediate". In its most general 23/// form, this can hold "SymbolA - SymbolB + imm64". Not all targets supports 24/// relocations of this general form, but we need to represent this anyway. 25///
| 20 21namespace llvm { 22class MCSymbol; 23 24/// MCValue - This represents an "assembler immediate". In its most general 25/// form, this can hold "SymbolA - SymbolB + imm64". Not all targets supports 26/// relocations of this general form, but we need to represent this anyway. 27///
|
| 28/// In the general form, SymbolB can only be defined if SymbolA is, and both 29/// must be in the same (non-external) section. The latter constraint is not 30/// enforced, since a symbol's section may not be known at construction. 31///
|
26/// Note that this class must remain a simple POD value class, because we need 27/// it to live in unions etc. 28class MCValue { 29 MCSymbol *SymA, *SymB; 30 int64_t Cst; 31public: 32
| 32/// Note that this class must remain a simple POD value class, because we need 33/// it to live in unions etc. 34class MCValue { 35 MCSymbol *SymA, *SymB; 36 int64_t Cst; 37public: 38
|
33 int64_t getCst() const { return Cst; }
| 39 int64_t getConstant() const { return Cst; }
|
34 MCSymbol *getSymA() const { return SymA; } 35 MCSymbol *getSymB() const { return SymB; }
| 40 MCSymbol *getSymA() const { return SymA; } 41 MCSymbol *getSymB() const { return SymB; }
|
36 37
| 42 43 /// isAbsolute - Is this an absolute (as opposed to relocatable) value. 44 bool isAbsolute() const { return !SymA && !SymB; } 45 46 /// getAssociatedSection - For relocatable values, return the section the 47 /// value is associated with. 48 /// 49 /// @result - The value's associated section, or null for external or constant 50 /// values. 51 MCSection *getAssociatedSection() const { 52 return SymA ? SymA->getSection() : 0; 53 } 54
|
38 static MCValue get(MCSymbol *SymA, MCSymbol *SymB = 0, int64_t Val = 0) { 39 MCValue R;
| 55 static MCValue get(MCSymbol *SymA, MCSymbol *SymB = 0, int64_t Val = 0) { 56 MCValue R;
|
| 57 assert((!SymB || SymA) && "Invalid relocatable MCValue!");
|
40 R.Cst = Val; 41 R.SymA = SymA; 42 R.SymB = SymB; 43 return R; 44 } 45 46 static MCValue get(int64_t Val) { 47 MCValue R; 48 R.Cst = Val; 49 R.SymA = 0; 50 R.SymB = 0; 51 return R; 52 } 53 54}; 55 56} // end namespace llvm 57 58#endif
| 58 R.Cst = Val; 59 R.SymA = SymA; 60 R.SymB = SymB; 61 return R; 62 } 63 64 static MCValue get(int64_t Val) { 65 MCValue R; 66 R.Cst = Val; 67 R.SymA = 0; 68 R.SymB = 0; 69 return R; 70 } 71 72}; 73 74} // end namespace llvm 75 76#endif
|