summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/X86/X86MCTargetExpr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Target/X86/X86MCTargetExpr.cpp')
-rw-r--r--llvm/lib/Target/X86/X86MCTargetExpr.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/llvm/lib/Target/X86/X86MCTargetExpr.cpp b/llvm/lib/Target/X86/X86MCTargetExpr.cpp
new file mode 100644
index 00000000000..1b0d75a0b5a
--- /dev/null
+++ b/llvm/lib/Target/X86/X86MCTargetExpr.cpp
@@ -0,0 +1,43 @@
+//===- X86MCTargetExpr.cpp - X86 Target Specific MCExpr Implementation ----===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "X86MCTargetExpr.h"
+#include "llvm/MC/MCContext.h"
+#include "llvm/MC/MCSymbol.h"
+#include "llvm/MC/MCValue.h"
+#include "llvm/Support/raw_ostream.h"
+using namespace llvm;
+
+X86MCTargetExpr *X86MCTargetExpr::Create(const MCSymbol *Sym, VariantKind K,
+ MCContext &Ctx) {
+ return new (Ctx) X86MCTargetExpr(Sym, K);
+}
+
+void X86MCTargetExpr::PrintImpl(raw_ostream &OS) const {
+ OS << *Sym;
+
+ switch (Kind) {
+ case GOT: OS << "@GOT"; break;
+ case PLT: OS << "@PLT"; break;
+ case GOTPCREL: OS << "@GOTPCREL"; break;
+ }
+}
+
+bool X86MCTargetExpr::EvaluateAsRelocatableImpl(MCValue &Res) const {
+ // FIXME: I don't know if this is right, it followed MCSymbolRefExpr.
+
+ // Evaluate recursively if this is a variable.
+ if (Sym->isVariable())
+ return Sym->getValue()->EvaluateAsRelocatable(Res);
+
+ Res = MCValue::get(Sym, 0, 0);
+ return true;
+}
+
+X86MCTargetExpr *foo(MCExpr *A) { return (X86MCTargetExpr*)A; } \ No newline at end of file
OpenPOWER on IntegriCloud