diff options
author | Mandeep Singh Grang <mgrang@codeaurora.org> | 2016-12-01 18:42:04 +0000 |
---|---|---|
committer | Mandeep Singh Grang <mgrang@codeaurora.org> | 2016-12-01 18:42:04 +0000 |
commit | 32360071a075c24f1ce133c9566b7bbd32b12578 (patch) | |
tree | 9257bae1bbdd3dfefaac76caf7b881368a3006b0 /llvm/lib/MC | |
parent | 17d5b6b4935175354c7af06cf2c2405237c85531 (diff) | |
download | bcm5719-llvm-32360071a075c24f1ce133c9566b7bbd32b12578.tar.gz bcm5719-llvm-32360071a075c24f1ce133c9566b7bbd32b12578.zip |
[llvm] Implement support for -defsym assembler option
Summary:
Changes to llvm-mc to move common logic to separate function.
Related clang patch: https://reviews.llvm.org/D26213
Reviewers: rafael, t.p.northover, colinl, echristo, rengolin
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D26214
llvm-svn: 288396
Diffstat (limited to 'llvm/lib/MC')
-rw-r--r-- | llvm/lib/MC/MCContext.cpp | 16 |
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 //===----------------------------------------------------------------------===// |