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