summaryrefslogtreecommitdiffstats
path: root/lld/ELF/LinkerScript.cpp
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2016-08-05 01:04:59 +0000
committerRui Ueyama <ruiu@google.com>2016-08-05 01:04:59 +0000
commit36c1cd235a74e5d3f84b01eec010f98b1ab65d7e (patch)
tree7bca0b787d8197b2cdaf4f232c44e09f7b6e9a8c /lld/ELF/LinkerScript.cpp
parent243bd763ecad466fac748b565ea52c661107684d (diff)
downloadbcm5719-llvm-36c1cd235a74e5d3f84b01eec010f98b1ab65d7e.tar.gz
bcm5719-llvm-36c1cd235a74e5d3f84b01eec010f98b1ab65d7e.zip
Make combine() non-member function.
Because this function depends only on its arguments. llvm-svn: 277790
Diffstat (limited to 'lld/ELF/LinkerScript.cpp')
-rw-r--r--lld/ELF/LinkerScript.cpp69
1 files changed, 34 insertions, 35 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index e4d264ef440..a2f611a1d49 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -502,7 +502,6 @@ private:
Expr readExpr1(Expr Lhs, int MinPrec);
Expr readPrimary();
Expr readTernary(Expr Cond);
- Expr combine(StringRef Op, Expr Lhs, Expr Rhs);
const static StringMap<Handler> Cmd;
ScriptConfiguration &Opt = *ScriptConfig;
@@ -941,6 +940,40 @@ SymbolAssignment *ScriptParser::readAssignment(StringRef Name) {
// script expression.
Expr ScriptParser::readExpr() { return readExpr1(readPrimary(), 0); }
+static Expr combine(StringRef Op, Expr L, Expr R) {
+ if (Op == "*")
+ return [=](uint64_t Dot) { return L(Dot) * R(Dot); };
+ if (Op == "/") {
+ return [=](uint64_t Dot) -> uint64_t {
+ uint64_t RHS = R(Dot);
+ if (RHS == 0) {
+ error("division by zero");
+ return 0;
+ }
+ return L(Dot) / RHS;
+ };
+ }
+ if (Op == "+")
+ return [=](uint64_t Dot) { return L(Dot) + R(Dot); };
+ if (Op == "-")
+ return [=](uint64_t Dot) { return L(Dot) - R(Dot); };
+ if (Op == "<")
+ return [=](uint64_t Dot) { return L(Dot) < R(Dot); };
+ if (Op == ">")
+ return [=](uint64_t Dot) { return L(Dot) > R(Dot); };
+ if (Op == ">=")
+ return [=](uint64_t Dot) { return L(Dot) >= R(Dot); };
+ if (Op == "<=")
+ return [=](uint64_t Dot) { return L(Dot) <= R(Dot); };
+ if (Op == "==")
+ return [=](uint64_t Dot) { return L(Dot) == R(Dot); };
+ if (Op == "!=")
+ return [=](uint64_t Dot) { return L(Dot) != R(Dot); };
+ if (Op == "&")
+ return [=](uint64_t Dot) { return L(Dot) & R(Dot); };
+ llvm_unreachable("invalid operator");
+}
+
// This is a part of the operator-precedence parser. This function
// assumes that the remaining token stream starts with an operator.
Expr ScriptParser::readExpr1(Expr Lhs, int MinPrec) {
@@ -1061,40 +1094,6 @@ Expr ScriptParser::readTernary(Expr Cond) {
return [=](uint64_t Dot) { return Cond(Dot) ? L(Dot) : R(Dot); };
}
-Expr ScriptParser::combine(StringRef Op, Expr L, Expr R) {
- if (Op == "*")
- return [=](uint64_t Dot) { return L(Dot) * R(Dot); };
- if (Op == "/") {
- return [=](uint64_t Dot) -> uint64_t {
- uint64_t RHS = R(Dot);
- if (RHS == 0) {
- error("division by zero");
- return 0;
- }
- return L(Dot) / RHS;
- };
- }
- if (Op == "+")
- return [=](uint64_t Dot) { return L(Dot) + R(Dot); };
- if (Op == "-")
- return [=](uint64_t Dot) { return L(Dot) - R(Dot); };
- if (Op == "<")
- return [=](uint64_t Dot) { return L(Dot) < R(Dot); };
- if (Op == ">")
- return [=](uint64_t Dot) { return L(Dot) > R(Dot); };
- if (Op == ">=")
- return [=](uint64_t Dot) { return L(Dot) >= R(Dot); };
- if (Op == "<=")
- return [=](uint64_t Dot) { return L(Dot) <= R(Dot); };
- if (Op == "==")
- return [=](uint64_t Dot) { return L(Dot) == R(Dot); };
- if (Op == "!=")
- return [=](uint64_t Dot) { return L(Dot) != R(Dot); };
- if (Op == "&")
- return [=](uint64_t Dot) { return L(Dot) & R(Dot); };
- llvm_unreachable("invalid operator");
-}
-
std::vector<StringRef> ScriptParser::readOutputSectionPhdrs() {
std::vector<StringRef> Phdrs;
while (!Error && peek().startswith(":")) {
OpenPOWER on IntegriCloud