diff options
author | Yizhe <yizhe@pku.edu.cn> | 2021-02-25 18:41:43 +0000 |
---|---|---|
committer | Philip Herron <herron.philip@googlemail.com> | 2021-03-01 10:42:27 +0000 |
commit | 6c5b2a63268212f63ab04f17b71c2abcc6aecefc (patch) | |
tree | e2e2dccfa2d6b9fd1960b6d0fafbc356d8eda34c /gcc/rust/rust-backend.h | |
parent | 63dabd8161f5d5c22a796286fb0c366742444c6e (diff) | |
download | gcc-6c5b2a63268212f63ab04f17b71c2abcc6aecefc.zip gcc-6c5b2a63268212f63ab04f17b71c2abcc6aecefc.tar.gz gcc-6c5b2a63268212f63ab04f17b71c2abcc6aecefc.tar.bz2 |
Rewrite backend to accept the new enum
Gcc_backend::unary_expression and Gcc_backend::binary_expression has
been split into 4 smaller functions corresponding to the 4 enums.
It turns out that keeping the 4 enums distinct helps simplify the logic
a lot. A lot of if-else branches were eliminated just by inlining the
type infomation.
There were also some minor cleanup. `operator_to_tree_code` function has
been modified to omit the `tree` parameter and offload floating-point
check to the caller.
Diffstat (limited to 'gcc/rust/rust-backend.h')
-rw-r--r-- | gcc/rust/rust-backend.h | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/gcc/rust/rust-backend.h b/gcc/rust/rust-backend.h index 7fb469b..394851a 100644 --- a/gcc/rust/rust-backend.h +++ b/gcc/rust/rust-backend.h @@ -362,19 +362,32 @@ public: Bexpression *else_expr, Location) = 0; - // Return an expression for the unary operation OP EXPR. - // Supported values of OP are (from operators.h): - // MINUS, NOT, XOR. - virtual Bexpression *unary_expression (Operator op, Bexpression *expr, - Location) - = 0; - - // Return an expression for the binary operation LEFT OP RIGHT. - // Supported values of OP are (from operators.h): - // EQEQ, NOTEQ, LT, LE, GT, GE, PLUS, MINUS, OR, XOR, MULT, DIV, MOD, - // LSHIFT, RSHIFT, AND, NOT. - virtual Bexpression *binary_expression (Operator op, Bexpression *left, - Bexpression *right, Location) + // Return an expression for the negation operation OP EXPR. + // Supported values of OP are enumerated in NegationOperator. + virtual Bexpression *negation_expression (NegationOperator op, + Bexpression *expr, Location) + = 0; + + // Return an expression for the operation LEFT OP RIGHT. + // Supported values of OP are enumerated in ArithmeticOrLogicalOperator. + virtual Bexpression * + arithmetic_or_logical_expression (ArithmeticOrLogicalOperator op, + Bexpression *left, Bexpression *right, + Location) + = 0; + + // Return an expression for the operation LEFT OP RIGHT. + // Supported values of OP are enumerated in ComparisionOperator. + virtual Bexpression *comparision_expression (ComparisionOperator op, + Bexpression *left, + Bexpression *right, Location) + = 0; + + // Return an expression for the operation LEFT OP RIGHT. + // Supported values of OP are enumerated in LazyBooleanOperator. + virtual Bexpression *lazy_boolean_expression (LazyBooleanOperator op, + Bexpression *left, + Bexpression *right, Location) = 0; // Return an expression that constructs BTYPE with VALS. BTYPE must be the |