1 //===-- llvm/MC/MCValue.h - MCValue class -----------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file contains the declaration of the MCValue class.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_MC_MCVALUE_H
14 #define LLVM_MC_MCVALUE_H
16 #include "llvm/MC/MCExpr.h"
17 #include "llvm/MC/MCSymbol.h"
18 #include "llvm/Support/DataTypes.h"
25 /// This represents an "assembler immediate".
27 /// In its most general form, this can hold ":Kind:(SymbolA - SymbolB +
28 /// imm64)". Not all targets supports relocations of this general form, but we
29 /// need to represent this anyway.
31 /// In general both SymbolA and SymbolB will also have a modifier
32 /// analogous to the top-level Kind. Current targets are not expected
33 /// to make use of both though. The choice comes down to whether
34 /// relocation modifiers apply to the closest symbol or the whole
37 /// Note that this class must remain a simple POD value class, because we need
38 /// it to live in unions etc.
40 const MCSymbolRefExpr
*SymA
= nullptr, *SymB
= nullptr;
46 int64_t getConstant() const { return Cst
; }
47 const MCSymbolRefExpr
*getSymA() const { return SymA
; }
48 const MCSymbolRefExpr
*getSymB() const { return SymB
; }
49 uint32_t getRefKind() const { return RefKind
; }
51 /// Is this an absolute (as opposed to relocatable) value.
52 bool isAbsolute() const { return !SymA
&& !SymB
; }
54 /// Print the value to the stream \p OS.
55 void print(raw_ostream
&OS
) const;
57 /// Print the value to stderr.
60 MCSymbolRefExpr::VariantKind
getAccessVariant() const;
62 static MCValue
get(const MCSymbolRefExpr
*SymA
,
63 const MCSymbolRefExpr
*SymB
= nullptr,
64 int64_t Val
= 0, uint32_t RefKind
= 0) {
73 static MCValue
get(int64_t Val
) {
84 } // end namespace llvm