blob: c6ea16ce7b4da3e0b35f4037ac3250bf66d54497 [file] [log] [blame]
Daniel Dunbar2c116242009-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 Dunbar9a1d2002010-03-18 00:59:10 +000011#include "llvm/MC/MCExpr.h"
David Greene24c802b2010-01-05 01:28:17 +000012#include "llvm/Support/Debug.h"
Daniel Dunbar2c116242009-08-14 03:11:09 +000013#include "llvm/Support/raw_ostream.h"
14
15using namespace llvm;
16
Chris Lattner684c593d2009-09-03 05:46:51 +000017void MCValue::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
Daniel Dunbar2c116242009-08-14 03:11:09 +000018 if (isAbsolute()) {
19 OS << getConstant();
20 return;
21 }
22
Daniel Dunbar9a1d2002010-03-18 00:59:10 +000023 getSymA()->print(OS);
Daniel Dunbar1689e0c2009-08-14 03:41:23 +000024
Daniel Dunbar9a1d2002010-03-18 00:59:10 +000025 if (getSymB()) {
26 OS << " - ";
27 getSymB()->print(OS);
28 }
Daniel Dunbar1689e0c2009-08-14 03:41:23 +000029
Daniel Dunbar2c116242009-08-14 03:11:09 +000030 if (getConstant())
31 OS << " + " << getConstant();
32}
33
34void MCValue::dump() const {
David Greene24c802b2010-01-05 01:28:17 +000035 print(dbgs(), 0);
Daniel Dunbar2c116242009-08-14 03:11:09 +000036}