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/System/DataTypes.h"
18 #include "llvm/MC/MCSymbol.h"
24 class MCSymbolRefExpr;
27 /// MCValue - This represents an "assembler immediate". In its most general
28 /// form, this can hold "SymbolA - SymbolB + imm64". Not all targets supports
29 /// relocations of this general form, but we need to represent this anyway.
31 /// In the general form, SymbolB can only be defined if SymbolA is, and both
32 /// must be in the same (non-external) section. The latter constraint is not
33 /// enforced, since a symbol's section may not be known at construction.
35 /// Note that this class must remain a simple POD value class, because we need
36 /// it to live in unions etc.
38 const MCSymbolRefExpr *SymA, *SymB;
42 int64_t getConstant() const { return Cst; }
43 const MCSymbolRefExpr *getSymA() const { return SymA; }
44 const MCSymbolRefExpr *getSymB() const { return SymB; }
46 /// isAbsolute - Is this an absolute (as opposed to relocatable) value.
47 bool isAbsolute() const { return !SymA && !SymB; }
49 /// getAssociatedSection - For relocatable values, return the section the
50 /// value is associated with.
52 /// @result - The value's associated section, or null for external or constant
55 // FIXME: Switch to a tagged section, so this can return the tagged section
57 const MCSection *getAssociatedSection() const;
59 /// print - Print the value to the stream \arg OS.
60 void print(raw_ostream &OS, const MCAsmInfo *MAI) const;
62 /// dump - Print the value to stderr.
65 static MCValue get(const MCSymbolRefExpr *SymA, const MCSymbolRefExpr *SymB=0,
68 assert((!SymB || SymA) && "Invalid relocatable MCValue!");
75 static MCValue get(int64_t Val) {
85 } // end namespace llvm