RISCV: clean up target expression handling
authorSaleem Abdulrasool <compnerd@compnerd.org>
Thu, 17 Jun 2021 17:09:22 +0000 (17:09 +0000)
committerSaleem Abdulrasool <abdulras@google.com>
Thu, 17 Jun 2021 20:35:32 +0000 (13:35 -0700)
commit116841c623747972d0ae80239d3ea7b8409b868b
tree16579b213b6120c664aa9828be330a26a8d1c047
parent71e4d434dc83b02a853712a5cb026ee2fa9ba67f
RISCV: clean up target expression handling

The target specific expression handling was slightly regressed by
bbea64250f65480d787e1c5ff45c4de3ec2dcda8.  This restores the proper
sub-expression evaluation to allow for constant folding within the
expression.  We explicitly discard the layout and assembler when
evaluating the expression to avoid any symbolic computation and instead
using the `evaluateAsRelocatable` to canonicalise and constant fold
only.

We can also simplify the expression handling - none of the target
variants support symbolic difference.  This simplifies the logic for
that and adds additional tests to ensure that we do not accidentally
regress here in the future.

Reviewed By: maskray

Differential Revision: https://reviews.llvm.org/D104473
llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp
llvm/test/MC/RISCV/expressions.s [new file with mode: 0644]