MCValue.cpp revision 36b56886974eae4f9c5ebc96befd3e7bfe5de338
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/MC/MCExpr.h"
12#include "llvm/Support/Debug.h"
13#include "llvm/Support/raw_ostream.h"
14
15using namespace llvm;
16
17void MCValue::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
18  if (isAbsolute()) {
19    OS << getConstant();
20    return;
21  }
22
23  // FIXME: prints as a number, which isn't ideal. But the meaning will be
24  // target-specific anyway.
25  if (getRefKind())
26    OS << ':' << getRefKind() <<  ':';
27
28  getSymA()->print(OS);
29
30  if (getSymB()) {
31    OS << " - ";
32    getSymB()->print(OS);
33  }
34
35  if (getConstant())
36    OS << " + " << getConstant();
37}
38
39#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
40void MCValue::dump() const {
41  print(dbgs(), 0);
42}
43#endif
44