summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/MC/MCContext.cpp')
-rw-r--r--llvm/lib/MC/MCContext.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 7932fe441e3..77fe015eefe 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -260,6 +260,22 @@ MCSymbol *MCContext::lookupSymbol(const Twine &Name) const {
return Symbols.lookup(NameRef);
}
+int MCContext::setSymbolValue(MCStreamer &Streamer, std::string &I) {
+ auto Pair = StringRef(I).split('=');
+ if (Pair.second.empty()) {
+ errs() << "error: defsym must be of the form: sym=value: " << I << "\n";
+ return 1;
+ }
+ int64_t Value;
+ if (Pair.second.getAsInteger(0, Value)) {
+ errs() << "error: Value is not an integer: " << Pair.second << "\n";
+ return 1;
+ }
+ auto Symbol = getOrCreateSymbol(Pair.first);
+ Streamer.EmitAssignment(Symbol, MCConstantExpr::create(Value, *this));
+ return 0;
+}
+
//===----------------------------------------------------------------------===//
// Section Management
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud