llvm.org GIT mirror llvm / e143a3a
[mips] [IAS] Add support for the .module softfloat/hardfloat directives. These directives are used to set the default value of the SoftFloat feature. They have the same effect as setting -m{soft, hard}-float from the command line. Differential Revision: http://reviews.llvm.org/D9073 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241066 91177308-0d34-0410-b5e6-96231b3b80d8 Toma Tabacu 4 years ago
5 changed file(s) with 100 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
47024702 /// ::= .module oddspreg
47034703 /// ::= .module nooddspreg
47044704 /// ::= .module fp=value
4705 /// ::= .module softfloat
4706 /// ::= .module hardfloat
47054707 bool MipsAsmParser::parseDirectiveModule() {
47064708 MCAsmParser &Parser = getParser();
47074709 MCAsmLexer &Lexer = getLexer();
47644766 return false; // parseDirectiveModule has finished successfully.
47654767 } else if (Option == "fp") {
47664768 return parseDirectiveModuleFP();
4769 } else if (Option == "softfloat") {
4770 setModuleFeatureBits(Mips::FeatureSoftFloat, "soft-float");
4771
4772 // Synchronize the ABI Flags information with the FeatureBits information we
4773 // updated above.
4774 getTargetStreamer().updateABIInfo(*this);
4775
4776 // If printing assembly, use the recently updated ABI Flags information.
4777 // If generating ELF, don't do anything (the .MIPS.abiflags section gets
4778 // emitted later).
4779 getTargetStreamer().emitDirectiveModuleSoftFloat();
4780
4781 // If this is not the end of the statement, report an error.
4782 if (getLexer().isNot(AsmToken::EndOfStatement)) {
4783 reportParseError("unexpected token, expected end of statement");
4784 return false;
4785 }
4786
4787 return false; // parseDirectiveModule has finished successfully.
4788 } else if (Option == "hardfloat") {
4789 clearModuleFeatureBits(Mips::FeatureSoftFloat, "soft-float");
4790
4791 // Synchronize the ABI Flags information with the FeatureBits information we
4792 // updated above.
4793 getTargetStreamer().updateABIInfo(*this);
4794
4795 // If printing assembly, use the recently updated ABI Flags information.
4796 // If generating ELF, don't do anything (the .MIPS.abiflags section gets
4797 // emitted later).
4798 getTargetStreamer().emitDirectiveModuleHardFloat();
4799
4800 // If this is not the end of the statement, report an error.
4801 if (getLexer().isNot(AsmToken::EndOfStatement)) {
4802 reportParseError("unexpected token, expected end of statement");
4803 return false;
4804 }
4805
4806 return false; // parseDirectiveModule has finished successfully.
47674807 } else {
47684808 return Error(L, "'" + Twine(Option) + "' is not a valid .module option.");
47694809 }
9898 if (!ABIFlagsSection.OddSPReg && !ABIFlagsSection.Is32BitABI)
9999 report_fatal_error("+nooddspreg is only valid for O32");
100100 }
101 void MipsTargetStreamer::emitDirectiveModuleSoftFloat() {}
102 void MipsTargetStreamer::emitDirectiveModuleHardFloat() {}
101103 void MipsTargetStreamer::emitDirectiveSetFp(
102104 MipsABIFlagsSection::FpABIKind Value) {
103105 forbidModuleDirective();
401403 void MipsTargetAsmStreamer::emitDirectiveSetNoOddSPReg() {
402404 MipsTargetStreamer::emitDirectiveSetNoOddSPReg();
403405 OS << "\t.set\tnooddspreg\n";
406 }
407
408 void MipsTargetAsmStreamer::emitDirectiveModuleSoftFloat() {
409 OS << "\t.module\tsoftfloat\n";
410 }
411
412 void MipsTargetAsmStreamer::emitDirectiveModuleHardFloat() {
413 OS << "\t.module\thardfloat\n";
404414 }
405415
406416 // This part is for ELF object output.
8282 // FP abiflags directives
8383 virtual void emitDirectiveModuleFP();
8484 virtual void emitDirectiveModuleOddSPReg();
85 virtual void emitDirectiveModuleSoftFloat();
86 virtual void emitDirectiveModuleHardFloat();
8587 virtual void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value);
8688 virtual void emitDirectiveSetOddSPReg();
8789 virtual void emitDirectiveSetNoOddSPReg();
191193 // FP abiflags directives
192194 void emitDirectiveModuleFP() override;
193195 void emitDirectiveModuleOddSPReg() override;
196 void emitDirectiveModuleSoftFloat() override;
197 void emitDirectiveModuleHardFloat() override;
194198 void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value) override;
195199 void emitDirectiveSetOddSPReg() override;
196200 void emitDirectiveSetNoOddSPReg() override;
0 # RUN: llvm-mc %s -arch=mips -mcpu=mips32 | \
1 # RUN: FileCheck %s -check-prefix=CHECK-ASM
2 #
3 # RUN: llvm-mc %s -arch=mips -mcpu=mips32 -filetype=obj -o - | \
4 # RUN: llvm-readobj -mips-abi-flags - | \
5 # RUN: FileCheck %s -check-prefix=CHECK-OBJ
6
7 # CHECK-ASM: .module hardfloat
8
9 # Check if the MIPS.abiflags section was correctly emitted:
10 # CHECK-OBJ: MIPS ABI Flags {
11 # CHECK-OBJ: FP ABI: Hard float (32-bit CPU, Any FPU) (0x5)
12 # CHECK-OBJ: CPR1 size: 32
13 # CHECK-OBJ: Flags 1 [ (0x1)
14 # CHECK-OBJ: ODDSPREG (0x1)
15 # CHECK-OBJ: ]
16 # CHECK-OBJ: }
17
18 .module fp=xx
19 .module oddspreg
20 .module softfloat
21 .module hardfloat
22
23 # FIXME: Test should include gnu_attributes directive when implemented.
24 # An explicit .gnu_attribute must be checked against the effective
25 # command line options and any inconsistencies reported via a warning.
0 # RUN: llvm-mc %s -arch=mips -mcpu=mips32 | \
1 # RUN: FileCheck %s -check-prefix=CHECK-ASM
2 #
3 # RUN: llvm-mc %s -arch=mips -mcpu=mips32 -filetype=obj -o - | \
4 # RUN: llvm-readobj -mips-abi-flags - | \
5 # RUN: FileCheck %s -check-prefix=CHECK-OBJ
6
7 # CHECK-ASM: .module softfloat
8
9 # Check if the MIPS.abiflags section was correctly emitted:
10 # CHECK-OBJ: MIPS ABI Flags {
11 # CHECK-OBJ: FP ABI: Soft float (0x3)
12 # CHECK-OBJ: CPR1 size: 0
13 # CHECK-OBJ: }
14
15 .module softfloat
16
17 # FIXME: Test should include gnu_attributes directive when implemented.
18 # An explicit .gnu_attribute must be checked against the effective
19 # command line options and any inconsistencies reported via a warning.