forked from OSchip/llvm-project
				
			[mips] Improve support for the .set mips16/nomips16 assembler directives.
Summary: Appropriately set/clear the FeatureBit for Mips16 when these assembler directives are used and also emit ".set nomips16" (previously, only ".set mips16" was being emitted). These improvements allow for better testing of the .cpload/.cprestore assembler directives (which are not supposed to work when Mips16 is enabled). Test Plan: The test is bare-bones because there are no MC tests for Mips16 instructions (there's only one, which checks that the Mips16 ELF header flag gets set), and that suggests to me that it has not been implemented yet in the IAS. Reviewers: dsanders Reviewed By: dsanders Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D5462 llvm-svn: 221277
This commit is contained in:
		
							parent
							
								
									7d434ce7e5
								
							
						
					
					
						commit
						cc2502d8f3
					
				| 
						 | 
					@ -200,6 +200,7 @@ class MipsAsmParser : public MCTargetAsmParser {
 | 
				
			||||||
  bool parseSetNoDspDirective();
 | 
					  bool parseSetNoDspDirective();
 | 
				
			||||||
  bool parseSetReorderDirective();
 | 
					  bool parseSetReorderDirective();
 | 
				
			||||||
  bool parseSetNoReorderDirective();
 | 
					  bool parseSetNoReorderDirective();
 | 
				
			||||||
 | 
					  bool parseSetMips16Directive();
 | 
				
			||||||
  bool parseSetNoMips16Directive();
 | 
					  bool parseSetNoMips16Directive();
 | 
				
			||||||
  bool parseSetFpDirective();
 | 
					  bool parseSetFpDirective();
 | 
				
			||||||
  bool parseSetPopDirective();
 | 
					  bool parseSetPopDirective();
 | 
				
			||||||
| 
						 | 
					@ -2783,14 +2784,32 @@ bool MipsAsmParser::parseSetNoDspDirective() {
 | 
				
			||||||
  return false;
 | 
					  return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool MipsAsmParser::parseSetNoMips16Directive() {
 | 
					bool MipsAsmParser::parseSetMips16Directive() {
 | 
				
			||||||
  Parser.Lex();
 | 
					  Parser.Lex(); // Eat "mips16".
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // If this is not the end of the statement, report an error.
 | 
					  // If this is not the end of the statement, report an error.
 | 
				
			||||||
  if (getLexer().isNot(AsmToken::EndOfStatement)) {
 | 
					  if (getLexer().isNot(AsmToken::EndOfStatement)) {
 | 
				
			||||||
    reportParseError("unexpected token, expected end of statement");
 | 
					    reportParseError("unexpected token, expected end of statement");
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  // For now do nothing.
 | 
					
 | 
				
			||||||
 | 
					  setFeatureBits(Mips::FeatureMips16, "mips16");
 | 
				
			||||||
 | 
					  getTargetStreamer().emitDirectiveSetMips16();
 | 
				
			||||||
 | 
					  Parser.Lex(); // Consume the EndOfStatement.
 | 
				
			||||||
 | 
					  return false;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool MipsAsmParser::parseSetNoMips16Directive() {
 | 
				
			||||||
 | 
					  Parser.Lex(); // Eat "nomips16".
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // If this is not the end of the statement, report an error.
 | 
				
			||||||
 | 
					  if (getLexer().isNot(AsmToken::EndOfStatement)) {
 | 
				
			||||||
 | 
					    reportParseError("unexpected token, expected end of statement");
 | 
				
			||||||
 | 
					    return false;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  clearFeatureBits(Mips::FeatureMips16, "mips16");
 | 
				
			||||||
 | 
					  getTargetStreamer().emitDirectiveSetNoMips16();
 | 
				
			||||||
  Parser.Lex(); // Consume the EndOfStatement.
 | 
					  Parser.Lex(); // Consume the EndOfStatement.
 | 
				
			||||||
  return false;
 | 
					  return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -2940,9 +2959,6 @@ bool MipsAsmParser::parseSetFeature(uint64_t Feature) {
 | 
				
			||||||
  case Mips::FeatureMicroMips:
 | 
					  case Mips::FeatureMicroMips:
 | 
				
			||||||
    getTargetStreamer().emitDirectiveSetMicroMips();
 | 
					    getTargetStreamer().emitDirectiveSetMicroMips();
 | 
				
			||||||
    break;
 | 
					    break;
 | 
				
			||||||
  case Mips::FeatureMips16:
 | 
					 | 
				
			||||||
    getTargetStreamer().emitDirectiveSetMips16();
 | 
					 | 
				
			||||||
    break;
 | 
					 | 
				
			||||||
  case Mips::FeatureMips1:
 | 
					  case Mips::FeatureMips1:
 | 
				
			||||||
    selectArch("mips1");
 | 
					    selectArch("mips1");
 | 
				
			||||||
    getTargetStreamer().emitDirectiveSetMips1();
 | 
					    getTargetStreamer().emitDirectiveSetMips1();
 | 
				
			||||||
| 
						 | 
					@ -3131,7 +3147,7 @@ bool MipsAsmParser::parseDirectiveSet() {
 | 
				
			||||||
  } else if (Tok.getString() == "nomacro") {
 | 
					  } else if (Tok.getString() == "nomacro") {
 | 
				
			||||||
    return parseSetNoMacroDirective();
 | 
					    return parseSetNoMacroDirective();
 | 
				
			||||||
  } else if (Tok.getString() == "mips16") {
 | 
					  } else if (Tok.getString() == "mips16") {
 | 
				
			||||||
    return parseSetFeature(Mips::FeatureMips16);
 | 
					    return parseSetMips16Directive();
 | 
				
			||||||
  } else if (Tok.getString() == "nomips16") {
 | 
					  } else if (Tok.getString() == "nomips16") {
 | 
				
			||||||
    return parseSetNoMips16Directive();
 | 
					    return parseSetNoMips16Directive();
 | 
				
			||||||
  } else if (Tok.getString() == "nomicromips") {
 | 
					  } else if (Tok.getString() == "nomicromips") {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,10 @@
 | 
				
			||||||
 | 
					# RUN: llvm-mc %s -arch=mips | FileCheck %s
 | 
				
			||||||
 | 
					# FIXME: Update this test when we have a more mature implementation of Mips16 in the IAS.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.text
 | 
				
			||||||
 | 
					.set mips16
 | 
				
			||||||
 | 
					.set nomips16
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# CHECK: .text
 | 
				
			||||||
 | 
					# CHECK: .set mips16
 | 
				
			||||||
 | 
					# CHECK: .set nomips16
 | 
				
			||||||
		Loading…
	
		Reference in New Issue