LLVM  8.0.1
MCValue.cpp
Go to the documentation of this file.
1 //===- lib/MC/MCValue.cpp - MCValue implementation ------------------------===//
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 #include "llvm/MC/MCValue.h"
11 #include "llvm/Config/llvm-config.h"
12 #include "llvm/MC/MCExpr.h"
13 #include "llvm/Support/Debug.h"
16 
17 using namespace llvm;
18 
19 void MCValue::print(raw_ostream &OS) const {
20  if (isAbsolute()) {
21  OS << getConstant();
22  return;
23  }
24 
25  // FIXME: prints as a number, which isn't ideal. But the meaning will be
26  // target-specific anyway.
27  if (getRefKind())
28  OS << ':' << getRefKind() << ':';
29 
30  OS << *getSymA();
31 
32  if (getSymB()) {
33  OS << " - ";
34  OS << *getSymB();
35  }
36 
37  if (getConstant())
38  OS << " + " << getConstant();
39 }
40 
41 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
43  print(dbgs());
44 }
45 #endif
46 
48  const MCSymbolRefExpr *B = getSymB();
49  if (B) {
51  llvm_unreachable("unsupported");
52  }
53 
54  const MCSymbolRefExpr *A = getSymA();
55  if (!A)
57 
59  if (Kind == MCSymbolRefExpr::VK_WEAKREF)
61  return Kind;
62 }
This class represents lattice values for constants.
Definition: AllocatorList.h:24
VariantKind getKind() const
Definition: MCExpr.h:338
bool isAbsolute() const
Is this an absolute (as opposed to relocatable) value.
Definition: MCValue.h:53
MCSymbolRefExpr::VariantKind getAccessVariant() const
Definition: MCValue.cpp:47
int64_t getConstant() const
Definition: MCValue.h:47
const MCSymbolRefExpr * getSymB() const
Definition: MCValue.h:49
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:166
#define LLVM_DUMP_METHOD
Definition: Compiler.h:74
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
const MCSymbolRefExpr * getSymA() const
Definition: MCValue.h:48
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void print(raw_ostream &OS) const
Print the value to the stream OS.
Definition: MCValue.cpp:19
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:133
uint32_t getRefKind() const
Definition: MCValue.h:50
const unsigned Kind
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
void dump() const
Print the value to stderr.
Definition: MCValue.cpp:42