[llvm-commits] [llvm] r78982 - in /llvm/trunk: include/llvm/MC/MCValue.h lib/MC/MCValue.cpp
Daniel Dunbar
daniel at zuster.org
Thu Aug 13 20:11:11 PDT 2009
Author: ddunbar
Date: Thu Aug 13 22:11:09 2009
New Revision: 78982
URL: http://llvm.org/viewvc/llvm-project?rev=78982&view=rev
Log:
Add MCValue::{print, dump}
Added:
llvm/trunk/lib/MC/MCValue.cpp
Modified:
llvm/trunk/include/llvm/MC/MCValue.h
Modified: llvm/trunk/include/llvm/MC/MCValue.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCValue.h?rev=78982&r1=78981&r2=78982&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCValue.h (original)
+++ llvm/trunk/include/llvm/MC/MCValue.h Thu Aug 13 22:11:09 2009
@@ -20,6 +20,7 @@
namespace llvm {
class MCSymbol;
+class raw_ostream;
/// MCValue - This represents an "assembler immediate". In its most general
/// form, this can hold "SymbolA - SymbolB + imm64". Not all targets supports
@@ -52,6 +53,12 @@
return SymA ? SymA->getSection() : 0;
}
+ /// print - Print the value to the stream \arg OS.
+ void print(raw_ostream &OS) const;
+
+ /// dump - Print the value to stderr.
+ void dump() const;
+
static MCValue get(MCSymbol *SymA, MCSymbol *SymB = 0, int64_t Val = 0) {
MCValue R;
assert((!SymB || SymA) && "Invalid relocatable MCValue!");
Added: llvm/trunk/lib/MC/MCValue.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCValue.cpp?rev=78982&view=auto
==============================================================================
--- llvm/trunk/lib/MC/MCValue.cpp (added)
+++ llvm/trunk/lib/MC/MCValue.cpp Thu Aug 13 22:11:09 2009
@@ -0,0 +1,30 @@
+//===- lib/MC/MCValue.cpp - MCValue implementation ------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/MC/MCValue.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace llvm;
+
+void MCValue::print(raw_ostream &OS) const {
+ if (isAbsolute()) {
+ OS << getConstant();
+ return;
+ }
+
+ OS << getSymA();
+ if (getSymB())
+ OS << " - " << getSymB();
+ if (getConstant())
+ OS << " + " << getConstant();
+}
+
+void MCValue::dump() const {
+ print(errs());
+}
More information about the llvm-commits
mailing list