LLVM 22.0.0git
MCValue.cpp
Go to the documentation of this file.
1//===- lib/MC/MCValue.cpp - MCValue implementation ------------------------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9#include "llvm/MC/MCValue.h"
10#include "llvm/Config/llvm-config.h"
11#include "llvm/MC/MCExpr.h"
12#include "llvm/MC/MCSymbol.h"
13#include "llvm/Support/Debug.h"
15
16using namespace llvm;
17
18void MCValue::print(raw_ostream &OS) const {
19 if (isAbsolute()) {
20 OS << getConstant();
21 return;
22 }
23
24 // FIXME: prints as a number, which isn't ideal. But the meaning will be
25 // target-specific anyway.
26 if (getSpecifier())
27 OS << ':' << getSpecifier() << ':';
28
29 SymA->print(OS, nullptr);
30
31 if (auto *B = getSubSym()) {
32 OS << " - ";
33 B->print(OS, nullptr);
34 }
35
36 if (getConstant())
37 OS << " + " << getConstant();
38}
39
40#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
41LLVM_DUMP_METHOD void MCValue::dump() const {
42 print(dbgs());
43}
44#endif
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition Compiler.h:638
int64_t getConstant() const
Definition MCValue.h:44
uint32_t getSpecifier() const
Definition MCValue.h:46
const MCSymbol * getSubSym() const
Definition MCValue.h:51
bool isAbsolute() const
Is this an absolute (as opposed to relocatable) value.
Definition MCValue.h:54
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:207