Index: lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp =================================================================== --- lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp +++ lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp @@ -1184,6 +1184,18 @@ Inst = TmpInst; break; } + case PPC::MFTB: { + if (STI.getFeatureBits()[PPC::DeprecatedMFTB]) { + assert(Inst.getNumOperands() == 2 && "Expecting two operands"); + + MCInst TmpInst; + TmpInst.setOpcode(PPC::MFSPR); + TmpInst.addOperand(Inst.getOperand(0)); + TmpInst.addOperand(Inst.getOperand(1)); + Inst = TmpInst; + } + break; + } } } Index: lib/Target/PowerPC/PPC.td =================================================================== --- lib/Target/PowerPC/PPC.td +++ lib/Target/PowerPC/PPC.td @@ -247,7 +247,7 @@ // PowerPC processors supported. // -def : Processor<"generic", G3Itineraries, [Directive32]>; +def : Processor<"generic", G3Itineraries, [Directive32, DeprecatedMFTB]>; def : ProcessorModel<"440", PPC440Model, [Directive440, FeatureISEL, FeatureFRES, FeatureFRSQRTE, FeatureICBT, FeatureBookE, @@ -257,37 +257,51 @@ FeatureICBT, FeatureBookE, FeatureMSYNC, DeprecatedMFTB]>; def : Processor<"601", G3Itineraries, [Directive601]>; -def : Processor<"602", G3Itineraries, [Directive602]>; +def : Processor<"602", G3Itineraries, [Directive602, + DeprecatedMFTB]>; def : Processor<"603", G3Itineraries, [Directive603, - FeatureFRES, FeatureFRSQRTE]>; + FeatureFRES, FeatureFRSQRTE, + DeprecatedMFTB]>; def : Processor<"603e", G3Itineraries, [Directive603, - FeatureFRES, FeatureFRSQRTE]>; + FeatureFRES, FeatureFRSQRTE, + DeprecatedMFTB]>; def : Processor<"603ev", G3Itineraries, [Directive603, - FeatureFRES, FeatureFRSQRTE]>; + FeatureFRES, FeatureFRSQRTE, + DeprecatedMFTB]>; def : Processor<"604", G3Itineraries, [Directive604, - FeatureFRES, FeatureFRSQRTE]>; + FeatureFRES, FeatureFRSQRTE, + DeprecatedMFTB]>; def : Processor<"604e", G3Itineraries, [Directive604, - FeatureFRES, FeatureFRSQRTE]>; + FeatureFRES, FeatureFRSQRTE, + DeprecatedMFTB]>; def : Processor<"620", G3Itineraries, [Directive620, - FeatureFRES, FeatureFRSQRTE]>; + FeatureFRES, FeatureFRSQRTE, + DeprecatedMFTB]>; def : Processor<"750", G4Itineraries, [Directive750, - FeatureFRES, FeatureFRSQRTE]>; + FeatureFRES, FeatureFRSQRTE, + DeprecatedMFTB]>; def : Processor<"g3", G3Itineraries, [Directive750, - FeatureFRES, FeatureFRSQRTE]>; + FeatureFRES, FeatureFRSQRTE, + DeprecatedMFTB]>; def : Processor<"7400", G4Itineraries, [Directive7400, FeatureAltivec, - FeatureFRES, FeatureFRSQRTE]>; + FeatureFRES, FeatureFRSQRTE, + DeprecatedMFTB]>; def : Processor<"g4", G4Itineraries, [Directive7400, FeatureAltivec, - FeatureFRES, FeatureFRSQRTE]>; + FeatureFRES, FeatureFRSQRTE, + DeprecatedMFTB]>; def : Processor<"7450", G4PlusItineraries, [Directive7400, FeatureAltivec, - FeatureFRES, FeatureFRSQRTE]>; + FeatureFRES, FeatureFRSQRTE, + DeprecatedMFTB]>; def : Processor<"g4+", G4PlusItineraries, [Directive7400, FeatureAltivec, - FeatureFRES, FeatureFRSQRTE]>; + FeatureFRES, FeatureFRSQRTE, + DeprecatedMFTB]>; def : ProcessorModel<"970", G5Model, [Directive970, FeatureAltivec, FeatureMFOCRF, FeatureFSqrt, FeatureFRES, FeatureFRSQRTE, FeatureSTFIWX, - Feature64Bit /*, Feature64BitRegs */]>; + Feature64Bit /*, Feature64BitRegs */, + DeprecatedMFTB]>; def : ProcessorModel<"g5", G5Model, [Directive970, FeatureAltivec, FeatureMFOCRF, FeatureFSqrt, FeatureSTFIWX, @@ -325,7 +339,7 @@ def : ProcessorModel<"pwr4", G5Model, [DirectivePwr4, FeatureAltivec, FeatureMFOCRF, FeatureFSqrt, FeatureFRES, FeatureFRSQRTE, - FeatureSTFIWX, Feature64Bit]>; + FeatureSTFIWX, Feature64Bit, DeprecatedMFTB]>; def : ProcessorModel<"pwr5", G5Model, [DirectivePwr5, FeatureAltivec, FeatureMFOCRF, FeatureFSqrt, FeatureFRE, FeatureFRES, @@ -354,12 +368,13 @@ DeprecatedMFTB, DeprecatedDST]>; def : ProcessorModel<"pwr7", P7Model, ProcessorFeatures.Power7FeatureList>; def : ProcessorModel<"pwr8", P8Model, ProcessorFeatures.Power8FeatureList>; -def : Processor<"ppc", G3Itineraries, [Directive32]>; +def : Processor<"ppc", G3Itineraries, [Directive32, DeprecatedMFTB]>; def : ProcessorModel<"ppc64", G5Model, [Directive64, FeatureAltivec, FeatureMFOCRF, FeatureFSqrt, FeatureFRES, FeatureFRSQRTE, FeatureSTFIWX, - Feature64Bit /*, Feature64BitRegs */]>; + Feature64Bit /*, Feature64BitRegs */, + DeprecatedMFTB]>; def : ProcessorModel<"ppc64le", P8Model, ProcessorFeatures.Power8FeatureList>; //===----------------------------------------------------------------------===// Index: lib/Target/PowerPC/PPCInstrInfo.td =================================================================== --- lib/Target/PowerPC/PPCInstrInfo.td +++ lib/Target/PowerPC/PPCInstrInfo.td @@ -2225,7 +2225,7 @@ "mtspr $SPR, $RT", IIC_SprMTSPR>; def MFTB : XFXForm_1<31, 371, (outs gprc:$RT), (ins i32imm:$SPR), - "mftb $RT, $SPR", IIC_SprMFTB>, Deprecated; + "mftb $RT, $SPR", IIC_SprMFTB>; // A pseudo-instruction used to implement the read of the 64-bit cycle counter // on a 32-bit target. Index: test/CodeGen/PowerPC/mftb.ll =================================================================== --- test/CodeGen/PowerPC/mftb.ll +++ test/CodeGen/PowerPC/mftb.ll @@ -0,0 +1,72 @@ +; Check handling of the mftb instruction. +; For CPUs 601 and pwr3, the mftb instruction should be emitted. +; On all other CPUs (including generic, ppc, ppc64), the mfspr instruction +; should be used instead. There should no longer be a deprecated warning +; message emittedfor this instruction for any CPU. + +; RUN: llc -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 < %s 2>&1 \ +; RUN: | FileCheck %s --check-prefix=CHECK-MFSPR +; RUN: llc -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr8 < %s 2>&1 \ +; RUN: | FileCheck %s --check-prefix=CHECK-MFSPR +; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu < %s 2>&1 \ +; RUN: | FileCheck %s --check-prefix=CHECK-MFSPR +; RUN: llc -mtriple=powerpc-unknown-linux-gnu < %s 2>&1 \ +; RUN: | FileCheck %s --check-prefix=CHECK-MFSPR +; RUN: llc -mtriple=powerpc-unknown-linux-gnu -mcpu=ppc < %s 2>&1 \ +; RUN: | FileCheck %s --check-prefix=CHECK-MFSPR +; RUN: llc -mtriple=powerpc-unknown-linux-gnu -mcpu=601 < %s 2>&1 \ +; RUN: | FileCheck %s --check-prefix=CHECK-MFTB +; RUN: llc -mtriple=powerpc-unknown-linux-gnu -mcpu=pwr3 < %s 2>&1 \ +; RUN: | FileCheck %s --check-prefix=CHECK-MFTB + +; CHECK-MFSPR-NOT: warning: deprecated +; CHECK-MFTB-NOT: warning: deprecated + +define i32 @get_time() { + %time = call i32 asm "mftb $0, 268", "=r"() + ret i32 %time +; CHECK-MFSPR-LABEL: @get_time +; CHECK-MFSPR: mfspr 3, 268 +; CHECK-MFSPR: blr + +; CHECK-MFTB-LABEL: @get_time +; CHECK-MFTB: mftb 3, 268 +; CHECK-MFTB: blr +} + +define i32 @get_timeu() { + %time = call i32 asm "mftb $0, 269", "=r"() + ret i32 %time +; CHECK-MFSPR-LABEL: @get_timeu +; CHECK-MFSPR: mfspr 3, 269 +; CHECK-MFSPR: blr + +; CHECK-MFTB-LABEL: @get_timeu +; CHECK-MFTB: mftbu 3 +; CHECK-MFTB: blr +} + +define i32 @get_time_e() { + %time = call i32 asm "mftb $0", "=r"() + ret i32 %time +; CHECK-MFSPR-LABEL: @get_time_e +; CHECK-MFSPR: mfspr 3, 268 +; CHECK-MFSPR: blr + +; CHECK-MFTB-LABEL: @get_time_e +; CHECK-MFTB: mftb 3, 268 +; CHECK-MFTB: blr +} + +define i32 @get_timeu_e() { + %time = call i32 asm "mftbu $0", "=r"() + ret i32 %time +; CHECK-MFSPR-LABEL: @get_timeu_e +; CHECK-MFSPR: mfspr 3, 269 +; CHECK-MFSPR: blr + +; CHECK-MFTB-LABEL: @get_timeu_e +; CHECK-MFTB: mftbu 3 +; CHECK-MFTB: blr +} + Index: test/MC/PowerPC/deprecated-p7.s =================================================================== --- test/MC/PowerPC/deprecated-p7.s +++ test/MC/PowerPC/deprecated-p7.s @@ -3,8 +3,8 @@ # RUN: llvm-mc -triple powerpc-unknown-linux-gnu -mcpu=601 -show-encoding < %s 2>&1 | FileCheck -check-prefix=CHECK-OLD %s mftb 3 -# CHECK: warning: deprecated -# CHECK: mftb 3 +# CHECK-NOT: warning: deprecated +# CHECK: mfspr 3, 268 # CHECK-OLD-NOT: warning: deprecated # CHECK-OLD: mftb 3