Index: llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp =================================================================== --- llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp +++ llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp @@ -420,6 +420,7 @@ bool parseAddressRegister(Register &Reg); bool ParseDirectiveInsn(SMLoc L); + bool ParseDirectiveMachine(SMLoc L); OperandMatchResultTy parseAddress(OperandVector &Operands, MemoryKind MemKind, @@ -1210,6 +1211,8 @@ if (IDVal == ".insn") return ParseDirectiveInsn(DirectiveID.getLoc()); + if (IDVal == ".machine") + return ParseDirectiveMachine(DirectiveID.getLoc()); return true; } @@ -1322,6 +1325,26 @@ return false; } +/// ParseDirectiveMachine +/// ::= .machine [ mcpu ] +bool SystemZAsmParser::ParseDirectiveMachine(SMLoc L) { + MCAsmParser &Parser = getParser(); + if (Parser.getTok().isNot(AsmToken::Identifier) && + Parser.getTok().isNot(AsmToken::String)) + return Error(L, "unexpected token in '.machine' directive"); + + StringRef CPU = Parser.getTok().getIdentifier(); + Parser.Lex(); + if (parseToken(AsmToken::EndOfStatement)) + return addErrorSuffix(" in '.machine' directive"); + + MCSubtargetInfo &STI = copySTI(); + STI.setDefaultFeatures(CPU, /*TuneCPU*/ CPU, ""); + setAvailableFeatures(ComputeAvailableFeatures(STI.getFeatureBits())); + + return false; +} + bool SystemZAsmParser::ParseRegister(unsigned &RegNo, SMLoc &StartLoc, SMLoc &EndLoc, bool RestoreOnFailure) { Register Reg; Index: llvm/test/MC/SystemZ/machine-directive.s =================================================================== --- /dev/null +++ llvm/test/MC/SystemZ/machine-directive.s @@ -0,0 +1,17 @@ +# RUN: not llvm-mc -triple=s390x-linux-gnu %s --filetype=asm 2>&1 | FileCheck %s + +# CHECK: error: instruction requires: vector +# CHECK: vgbm %v0, 1 +# CHECK: ^ + +# CHECK-NOT: error: +# CHECK: vgbm %v0, 0 +# CHECK: vgbm %v0, 3 + +.machine z13 +vgbm %v0, 0 +.machine zEC12 +vgbm %v0, 1 +.machine z13 +vgbm %v0, 3 +