[llvm-branch-commits] [llvm] 7c4555f - [PowerPC] Delete remnant Darwin code in PPCAsmParser
Fangrui Song via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Nov 30 10:21:07 PST 2020
Author: Fangrui Song
Date: 2020-11-30T10:16:19-08:00
New Revision: 7c4555f60d96d8a3ed35d74dab7e591dacc24b8d
URL: https://github.com/llvm/llvm-project/commit/7c4555f60d96d8a3ed35d74dab7e591dacc24b8d
DIFF: https://github.com/llvm/llvm-project/commit/7c4555f60d96d8a3ed35d74dab7e591dacc24b8d.diff
LOG: [PowerPC] Delete remnant Darwin code in PPCAsmParser
Continue the work started at D50989.
The code has been long dead since the triple has been removed (D75494).
Reviewed By: nickdesaulniers, void
Differential Revision: https://reviews.llvm.org/D91836
Added:
Modified:
llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp b/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
index 5d87e13752dd..748716126836 100644
--- a/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
+++ b/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
@@ -99,12 +99,10 @@ struct PPCOperand;
class PPCAsmParser : public MCTargetAsmParser {
bool IsPPC64;
- bool IsDarwin;
void Warning(SMLoc L, const Twine &Msg) { getParser().Warning(L, Msg); }
bool isPPC64() const { return IsPPC64; }
- bool isDarwin() const { return IsDarwin; }
bool MatchRegisterName(unsigned &RegNo, int64_t &IntVal);
@@ -116,14 +114,12 @@ class PPCAsmParser : public MCTargetAsmParser {
PPCMCExpr::VariantKind &Variant);
const MCExpr *FixupVariantKind(const MCExpr *E);
bool ParseExpression(const MCExpr *&EVal);
- bool ParseDarwinExpression(const MCExpr *&EVal);
bool ParseOperand(OperandVector &Operands);
bool ParseDirectiveWord(unsigned Size, AsmToken ID);
bool ParseDirectiveTC(unsigned Size, AsmToken ID);
bool ParseDirectiveMachine(SMLoc L);
- bool ParseDarwinDirectiveMachine(SMLoc L);
bool ParseDirectiveAbiVersion(SMLoc L);
bool ParseDirectiveLocalEntry(SMLoc L);
@@ -150,7 +146,6 @@ class PPCAsmParser : public MCTargetAsmParser {
// Check for 64-bit vs. 32-bit pointer mode.
const Triple &TheTriple = STI.getTargetTriple();
IsPPC64 = TheTriple.isPPC64();
- IsDarwin = TheTriple.isMacOSX();
// Initialize the set of available features.
setAvailableFeatures(ComputeAvailableFeatures(STI.getFeatureBits()));
}
@@ -1404,10 +1399,6 @@ FixupVariantKind(const MCExpr *E) {
/// it handles modifiers.
bool PPCAsmParser::
ParseExpression(const MCExpr *&EVal) {
-
- if (isDarwin())
- return ParseDarwinExpression(EVal);
-
// (ELF Platforms)
// Handle \code @l/@ha \endcode
if (getParser().parseExpression(EVal))
@@ -1423,53 +1414,6 @@ ParseExpression(const MCExpr *&EVal) {
return false;
}
-/// ParseDarwinExpression. (MachO Platforms)
-/// This
diff ers from the default "parseExpression" in that it handles detection
-/// of the \code hi16(), ha16() and lo16() \endcode modifiers. At present,
-/// parseExpression() doesn't recognise the modifiers when in the Darwin/MachO
-/// syntax form so it is done here. TODO: Determine if there is merit in
-/// arranging for this to be done at a higher level.
-bool PPCAsmParser::
-ParseDarwinExpression(const MCExpr *&EVal) {
- MCAsmParser &Parser = getParser();
- PPCMCExpr::VariantKind Variant = PPCMCExpr::VK_PPC_None;
- switch (getLexer().getKind()) {
- default:
- break;
- case AsmToken::Identifier:
- // Compiler-generated Darwin identifiers begin with L,l,_ or "; thus
- // something starting with any other char should be part of the
- // asm syntax. If handwritten asm includes an identifier like lo16,
- // then all bets are off - but no-one would do that, right?
- StringRef poss = Parser.getTok().getString();
- if (poss.equals_lower("lo16")) {
- Variant = PPCMCExpr::VK_PPC_LO;
- } else if (poss.equals_lower("hi16")) {
- Variant = PPCMCExpr::VK_PPC_HI;
- } else if (poss.equals_lower("ha16")) {
- Variant = PPCMCExpr::VK_PPC_HA;
- }
- if (Variant != PPCMCExpr::VK_PPC_None) {
- Parser.Lex(); // Eat the xx16
- if (getLexer().isNot(AsmToken::LParen))
- return Error(Parser.getTok().getLoc(), "expected '('");
- Parser.Lex(); // Eat the '('
- }
- break;
- }
-
- if (getParser().parseExpression(EVal))
- return true;
-
- if (Variant != PPCMCExpr::VK_PPC_None) {
- if (getLexer().isNot(AsmToken::RParen))
- return Error(Parser.getTok().getLoc(), "expected ')'");
- Parser.Lex(); // Eat the ')'
- EVal = PPCMCExpr::create(Variant, EVal, getParser().getContext());
- }
- return false;
-}
-
/// ParseOperand
/// This handles registers in the form 'NN', '%rNN' for ELF platforms and
/// rNN for MachO.
@@ -1501,20 +1445,6 @@ bool PPCAsmParser::ParseOperand(OperandVector &Operands) {
case AsmToken::Dollar:
case AsmToken::Exclaim:
case AsmToken::Tilde:
- // Note that non-register-name identifiers from the compiler will begin
- // with '_', 'L'/'l' or '"'. Of course, handwritten asm could include
- // identifiers like r31foo - so we fall through in the event that parsing
- // a register name fails.
- if (isDarwin()) {
- unsigned RegNo;
- int64_t IntVal;
- if (!MatchRegisterName(RegNo, IntVal)) {
- Operands.push_back(PPCOperand::CreateImm(IntVal, S, E, isPPC64()));
- return false;
- }
- }
- // All other expressions
-
if (!ParseExpression(EVal))
break;
// Fall-through
@@ -1560,21 +1490,11 @@ bool PPCAsmParser::ParseOperand(OperandVector &Operands) {
break;
}
case AsmToken::Integer:
- if (isDarwin())
- return Error(S, "unexpected integer value");
- else if (getParser().parseAbsoluteExpression(IntVal) || IntVal < 0 ||
- IntVal > 31)
+ if (getParser().parseAbsoluteExpression(IntVal) || IntVal < 0 ||
+ IntVal > 31)
return Error(S, "invalid register number");
break;
- case AsmToken::Identifier:
- if (isDarwin()) {
- unsigned RegNo;
- if (!MatchRegisterName(RegNo, IntVal)) {
- break;
- }
- }
- LLVM_FALLTHROUGH;
-
+ case AsmToken::Identifier:
default:
return Error(S, "invalid memory operand");
}
@@ -1658,12 +1578,7 @@ bool PPCAsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
/// ParseDirective parses the PPC specific directives
bool PPCAsmParser::ParseDirective(AsmToken DirectiveID) {
StringRef IDVal = DirectiveID.getIdentifier();
- if (isDarwin()) {
- if (IDVal == ".machine")
- ParseDarwinDirectiveMachine(DirectiveID.getLoc());
- else
- return true;
- } else if (IDVal == ".word")
+ if (IDVal == ".word")
ParseDirectiveWord(2, DirectiveID);
else if (IDVal == ".llong")
ParseDirectiveWord(8, DirectiveID);
@@ -1754,31 +1669,6 @@ bool PPCAsmParser::ParseDirectiveMachine(SMLoc L) {
return false;
}
-/// ParseDarwinDirectiveMachine (Mach-o platforms)
-/// ::= .machine cpu-identifier
-bool PPCAsmParser::ParseDarwinDirectiveMachine(SMLoc L) {
- MCAsmParser &Parser = getParser();
- if (Parser.getTok().isNot(AsmToken::Identifier) &&
- Parser.getTok().isNot(AsmToken::String))
- return Error(L, "unexpected token in directive");
-
- StringRef CPU = Parser.getTok().getIdentifier();
- Parser.Lex();
-
- // FIXME: this is only the 'default' set of cpu variants.
- // However we don't act on this information at present, this is simply
- // allowing parsing to proceed with minimal sanity checking.
- if (check(CPU != "ppc7400" && CPU != "ppc" && CPU != "ppc64", L,
- "unrecognized cpu type") ||
- check(isPPC64() && (CPU == "ppc7400" || CPU == "ppc"), L,
- "wrong cpu type specified for 64bit") ||
- check(!isPPC64() && CPU == "ppc64", L,
- "wrong cpu type specified for 32bit") ||
- parseToken(AsmToken::EndOfStatement))
- return addErrorSuffix(" in '.machine' directive");
- return false;
-}
-
/// ParseDirectiveAbiVersion
/// ::= .abiversion constant-expression
bool PPCAsmParser::ParseDirectiveAbiVersion(SMLoc L) {
diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
index e2d90a846e3d..f75182ca5319 100644
--- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -32,7 +32,6 @@
#include "llvm/ADT/Triple.h"
#include "llvm/ADT/Twine.h"
#include "llvm/BinaryFormat/ELF.h"
-#include "llvm/BinaryFormat/MachO.h"
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFunction.h"
@@ -53,7 +52,6 @@
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstBuilder.h"
#include "llvm/MC/MCSectionELF.h"
-#include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MCSectionXCOFF.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h"
@@ -1220,10 +1218,6 @@ void PPCAsmPrinter::emitInstruction(const MachineInstr *MI) {
case PPC::LWA: {
// Verify alignment is legal, so we don't create relocations
// that can't be supported.
- // FIXME: This test is currently disabled for Darwin. The test
- // suite shows a handful of test cases that fail this check for
- // Darwin. Those need to be investigated before this sanity test
- // can be enabled for those subtargets.
unsigned OpNum = (MI->getOpcode() == PPC::STD) ? 2 : 1;
const MachineOperand &MO = MI->getOperand(OpNum);
if (MO.isGlobal()) {
@@ -2062,10 +2056,8 @@ void PPCAIXAsmPrinter::emitXXStructorList(const DataLayout &DL,
}
}
-/// createPPCAsmPrinterPass - Returns a pass that prints the PPC assembly code
-/// for a MachineFunction to the given output stream, in a format that the
-/// Darwin assembler can deal with.
-///
+// Return a pass that prints the PPC assembly code for a MachineFunction to the
+// given output stream.
static AsmPrinter *
createPPCAsmPrinterPass(TargetMachine &tm,
std::unique_ptr<MCStreamer> &&Streamer) {
More information about the llvm-branch-commits
mailing list