1 //===-- llvm/MC/MCValue.h - MCValue class -----------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the declaration of the MCValue class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_MC_MCVALUE_H
15 #define LLVM_MC_MCVALUE_H
17 #include "llvm/Support/DataTypes.h"
18 #include "llvm/MC/MCSymbol.h"
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.
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.
32 /// Note that this class must remain a simple POD value class, because we need
33 /// it to live in unions etc.
35 MCSymbol *SymA, *SymB;
39 int64_t getConstant() const { return Cst; }
40 MCSymbol *getSymA() const { return SymA; }
41 MCSymbol *getSymB() const { return SymB; }
43 /// isAbsolute - Is this an absolute (as opposed to relocatable) value.
44 bool isAbsolute() const { return !SymA && !SymB; }
46 /// getAssociatedSection - For relocatable values, return the section the
47 /// value is associated with.
49 /// @result - The value's associated section, or null for external or constant
51 MCSection *getAssociatedSection() const {
52 return SymA ? SymA->getSection() : 0;
55 static MCValue get(MCSymbol *SymA, MCSymbol *SymB = 0, int64_t Val = 0) {
57 assert((!SymB || SymA) && "Invalid relocatable MCValue!");
64 static MCValue get(int64_t Val) {
74 } // end namespace llvm