blob: c1222ec88721c1dcb347bc762ef9d890fce8938d [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"
David Greene24c802b2010-01-05 01:28:17 +000011#include "llvm/Support/Debug.h"
Daniel Dunbar2c116242009-08-14 03:11:09 +000012#include "llvm/Support/raw_ostream.h"
13
14using namespace llvm;
15
Chris Lattner684c593d2009-09-03 05:46:51 +000016void MCValue::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
Daniel Dunbar2c116242009-08-14 03:11:09 +000017 if (isAbsolute()) {
18 OS << getConstant();
19 return;
20 }
21
Chris Lattner684c593d2009-09-03 05:46:51 +000022 getSymA()->print(OS, MAI);
Daniel Dunbar1689e0c2009-08-14 03:41:23 +000023
24 if (getSymB()) {
25 OS << " - ";
Chris Lattner684c593d2009-09-03 05:46:51 +000026 getSymB()->print(OS, MAI);
Daniel Dunbar1689e0c2009-08-14 03:41:23 +000027 }
28
Daniel Dunbar2c116242009-08-14 03:11:09 +000029 if (getConstant())
30 OS << " + " << getConstant();
31}
32
33void MCValue::dump() const {
David Greene24c802b2010-01-05 01:28:17 +000034 print(dbgs(), 0);
Daniel Dunbar2c116242009-08-14 03:11:09 +000035}