Daniel Dunbar | 2c11624 | 2009-08-14 03:11:09 +0000 | [diff] [blame] | 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" |
Daniel Dunbar | 9a1d200 | 2010-03-18 00:59:10 +0000 | [diff] [blame] | 11 | #include "llvm/MC/MCExpr.h" |
David Greene | 24c802b | 2010-01-05 01:28:17 +0000 | [diff] [blame] | 12 | #include "llvm/Support/Debug.h" |
Daniel Dunbar | 2c11624 | 2009-08-14 03:11:09 +0000 | [diff] [blame] | 13 | #include "llvm/Support/raw_ostream.h" |
| 14 | |
| 15 | using namespace llvm; |
| 16 | |
Chris Lattner | 684c593d | 2009-09-03 05:46:51 +0000 | [diff] [blame] | 17 | void MCValue::print(raw_ostream &OS, const MCAsmInfo *MAI) const { |
Daniel Dunbar | 2c11624 | 2009-08-14 03:11:09 +0000 | [diff] [blame] | 18 | if (isAbsolute()) { |
| 19 | OS << getConstant(); |
| 20 | return; |
| 21 | } |
| 22 | |
Daniel Dunbar | 9a1d200 | 2010-03-18 00:59:10 +0000 | [diff] [blame] | 23 | getSymA()->print(OS); |
Daniel Dunbar | 1689e0c | 2009-08-14 03:41:23 +0000 | [diff] [blame] | 24 | |
Daniel Dunbar | 9a1d200 | 2010-03-18 00:59:10 +0000 | [diff] [blame] | 25 | if (getSymB()) { |
| 26 | OS << " - "; |
| 27 | getSymB()->print(OS); |
| 28 | } |
Daniel Dunbar | 1689e0c | 2009-08-14 03:41:23 +0000 | [diff] [blame] | 29 | |
Daniel Dunbar | 2c11624 | 2009-08-14 03:11:09 +0000 | [diff] [blame] | 30 | if (getConstant()) |
| 31 | OS << " + " << getConstant(); |
| 32 | } |
| 33 | |
| 34 | void MCValue::dump() const { |
David Greene | 24c802b | 2010-01-05 01:28:17 +0000 | [diff] [blame] | 35 | print(dbgs(), 0); |
Daniel Dunbar | 2c11624 | 2009-08-14 03:11:09 +0000 | [diff] [blame] | 36 | } |