blob: 68ecffbeab144bda3d30a73bd061446d8b3e50e2 [file] [log] [blame]
Daniel Dunbarafe66032009-08-14 03:11:09 +00001//===- 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"
Daniel Dunbar9c64ec02010-03-18 00:59:10 +000011#include "llvm/MC/MCExpr.h"
David Greeneac7f5372010-01-05 01:28:17 +000012#include "llvm/Support/Debug.h"
Daniel Dunbarafe66032009-08-14 03:11:09 +000013#include "llvm/Support/raw_ostream.h"
14
15using namespace llvm;
16
Chris Lattnerf4366a32009-09-03 05:46:51 +000017void MCValue::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
Daniel Dunbarafe66032009-08-14 03:11:09 +000018 if (isAbsolute()) {
19 OS << getConstant();
20 return;
21 }
22
Tim Northover0999cbd2014-03-29 08:22:20 +000023 // 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
Daniel Dunbar9c64ec02010-03-18 00:59:10 +000028 getSymA()->print(OS);
Daniel Dunbar1a019d82009-08-14 03:41:23 +000029
Daniel Dunbar9c64ec02010-03-18 00:59:10 +000030 if (getSymB()) {
31 OS << " - ";
32 getSymB()->print(OS);
33 }
Daniel Dunbar1a019d82009-08-14 03:41:23 +000034
Daniel Dunbarafe66032009-08-14 03:11:09 +000035 if (getConstant())
36 OS << " + " << getConstant();
37}
38
Manman Ren49d684e2012-09-12 05:06:18 +000039#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
Daniel Dunbarafe66032009-08-14 03:11:09 +000040void MCValue::dump() const {
David Greeneac7f5372010-01-05 01:28:17 +000041 print(dbgs(), 0);
Daniel Dunbarafe66032009-08-14 03:11:09 +000042}
Manman Renc3366cc2012-09-06 19:55:56 +000043#endif