blob: c6ea16ce7b4da3e0b35f4037ac3250bf66d54497 [file] [log] [blame]
Shih-wei Liaoe264f622010-02-10 11:10:31 -08001//===- 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"
Shih-wei Liao7abe37e2010-04-28 01:47:00 -070011#include "llvm/MC/MCExpr.h"
Shih-wei Liaoe264f622010-02-10 11:10:31 -080012#include "llvm/Support/Debug.h"
13#include "llvm/Support/raw_ostream.h"
14
15using namespace llvm;
16
17void MCValue::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
18 if (isAbsolute()) {
19 OS << getConstant();
20 return;
21 }
22
Shih-wei Liao7abe37e2010-04-28 01:47:00 -070023 getSymA()->print(OS);
Shih-wei Liaoe264f622010-02-10 11:10:31 -080024
Shih-wei Liao7abe37e2010-04-28 01:47:00 -070025 if (getSymB()) {
26 OS << " - ";
27 getSymB()->print(OS);
28 }
Shih-wei Liaoe264f622010-02-10 11:10:31 -080029
30 if (getConstant())
31 OS << " + " << getConstant();
32}
33
34void MCValue::dump() const {
35 print(dbgs(), 0);
36}