summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/RISCV/AsmParser
diff options
context:
space:
mode:
authorAlex Bradbury <asb@lowrisc.org>2018-04-18 19:02:31 +0000
committerAlex Bradbury <asb@lowrisc.org>2018-04-18 19:02:31 +0000
commit099c720426b2e54fc17c8fddc270ea9a8ca2e356 (patch)
tree452bb232a9c6b6ff04f3a0859da68c6ced2a6ecb /llvm/lib/Target/RISCV/AsmParser
parent5832eb4cfd2fcb20fc9f25b9d9bdc2930df3cb27 (diff)
downloadbcm5719-llvm-099c720426b2e54fc17c8fddc270ea9a8ca2e356.tar.gz
bcm5719-llvm-099c720426b2e54fc17c8fddc270ea9a8ca2e356.zip
Revert "[RISCV] implement li pseudo instruction"
Reverts rL330224, while issues with the C extension and missed common subexpression elimination opportunities are addressed. Neither of these issues are visible in current RISC-V backend unit tests, which clearly need expanding. llvm-svn: 330281
Diffstat (limited to 'llvm/lib/Target/RISCV/AsmParser')
-rw-r--r--llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp69
1 files changed, 10 insertions, 59 deletions
diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 7f0433410d0..521d72b546d 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -9,7 +9,6 @@
#include "MCTargetDesc/RISCVBaseInfo.h"
#include "MCTargetDesc/RISCVMCExpr.h"
-#include "MCTargetDesc/RISCVMCPseudoExpansion.h"
#include "MCTargetDesc/RISCVMCTargetDesc.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringSwitch.h"
@@ -23,11 +22,8 @@
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/Support/Casting.h"
-#include "llvm/Support/MathExtras.h"
#include "llvm/Support/TargetRegistry.h"
-#include <limits>
-
using namespace llvm;
// Include the auto-generated portion of the compress emitter.
@@ -45,7 +41,7 @@ class RISCVAsmParser : public MCTargetAsmParser {
unsigned Kind) override;
bool generateImmOutOfRangeError(OperandVector &Operands, uint64_t ErrorInfo,
- int64_t Lower, int64_t Upper, Twine Msg);
+ int Lower, int Upper, Twine Msg);
bool MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
OperandVector &Operands, MCStreamer &Out,
@@ -59,12 +55,6 @@ class RISCVAsmParser : public MCTargetAsmParser {
bool ParseDirective(AsmToken DirectiveID) override;
- /// Helper for emitting MC instructions that have been successfully matched
- /// by MatchAndEmitInstruction. Modifications to the emitted instructions,
- /// like the expansion of pseudo instructions (e.g., "li"), can be performed
- /// in this method.
- bool processInstruction(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out);
-
// Auto-generated instruction matching functions
#define GET_ASSEMBLER_HEADER
#include "RISCVGenAsmMatcher.inc"
@@ -220,18 +210,6 @@ public:
return RISCVFPRndMode::stringToRoundingMode(Str) != RISCVFPRndMode::Invalid;
}
- bool isImmXLen() const {
- int64_t Imm;
- RISCVMCExpr::VariantKind VK;
- if (!isImm())
- return false;
- bool IsConstantImm = evaluateConstantImm(Imm, VK);
- // Given only Imm, ensuring that the actually specified constant is either
- // a signed or unsigned 64-bit number is unfortunately impossible.
- bool IsInRange = isRV64() ? true : isInt<32>(Imm) || isUInt<32>(Imm);
- return IsConstantImm && IsInRange && VK == RISCVMCExpr::VK_RISCV_None;
- }
-
bool isUImmLog2XLen() const {
int64_t Imm;
RISCVMCExpr::VariantKind VK;
@@ -605,7 +583,7 @@ unsigned RISCVAsmParser::validateTargetOperandClass(MCParsedAsmOperand &AsmOp,
}
bool RISCVAsmParser::generateImmOutOfRangeError(
- OperandVector &Operands, uint64_t ErrorInfo, int64_t Lower, int64_t Upper,
+ OperandVector &Operands, uint64_t ErrorInfo, int Lower, int Upper,
Twine Msg = "immediate must be an integer in the range") {
SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc();
return Error(ErrorLoc, Msg + " [" + Twine(Lower) + ", " + Twine(Upper) + "]");
@@ -621,8 +599,14 @@ bool RISCVAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
switch (MatchInstructionImpl(Operands, Inst, ErrorInfo, MatchingInlineAsm)) {
default:
break;
- case Match_Success:
- return processInstruction(Inst, IDLoc, Out);
+ case Match_Success: {
+ MCInst CInst;
+ bool Res = compressInst(CInst, Inst, getSTI(), Out.getContext());
+ CInst.setLoc(IDLoc);
+ Inst.setLoc(IDLoc);
+ Out.EmitInstruction((Res ? CInst : Inst), getSTI());
+ return false;
+ }
case Match_MissingFeature:
return Error(IDLoc, "instruction use requires an option to be enabled");
case Match_MnemonicFail:
@@ -639,14 +623,6 @@ bool RISCVAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
}
return Error(ErrorLoc, "invalid operand for instruction");
}
- case Match_InvalidImmXLen:
- if (isRV64()) {
- SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc();
- return Error(ErrorLoc, "operand must be a constant 64-bit integer");
- }
- return generateImmOutOfRangeError(Operands, ErrorInfo,
- std::numeric_limits<int32_t>::min(),
- std::numeric_limits<uint32_t>::max());
case Match_InvalidUImmLog2XLen:
if (isRV64())
return generateImmOutOfRangeError(Operands, ErrorInfo, 0, (1 << 6) - 1);
@@ -991,31 +967,6 @@ bool RISCVAsmParser::classifySymbolRef(const MCExpr *Expr,
return Kind != RISCVMCExpr::VK_RISCV_Invalid;
}
-bool RISCVAsmParser::processInstruction(MCInst &Inst, SMLoc IDLoc,
- MCStreamer &Out) {
- Inst.setLoc(IDLoc);
-
- switch (Inst.getOpcode()) {
- case RISCV::PseudoLI: {
- auto Reg = Inst.getOperand(0).getReg();
- int64_t Imm = Inst.getOperand(1).getImm();
- // On RV32 the immediate here can either be a signed or an unsigned
- // 32-bit number. Sign extension has to be performed to ensure that Imm
- // represents the expected signed 64-bit number.
- if (!isRV64())
- Imm = SignExtend64<32>(Imm);
- emitRISCVLoadImm(Reg, Imm, Out, STI);
- return false;
- }
- }
-
- MCInst CInst;
- bool Res = compressInst(CInst, Inst, getSTI(), Out.getContext());
- CInst.setLoc(IDLoc);
- Out.EmitInstruction((Res ? CInst : Inst), getSTI());
- return false;
-}
-
bool RISCVAsmParser::ParseDirective(AsmToken DirectiveID) { return true; }
extern "C" void LLVMInitializeRISCVAsmParser() {
OpenPOWER on IntegriCloud