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