forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LoongArch] [CodeGen] Add options for Clang to generate LoongArch-spe…
…cific frecipe & frsqrte instructions (llvm#109917) Two options: `-mfrecipe` & `-mno-frecipe`. Enable or Disable frecipe.{s/d} and frsqrte.{s/d} instructions. The default is `-mno-frecipe`.
- Loading branch information
Showing
15 changed files
with
1,411 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/// Test -m[no]frecipe options. | ||
|
||
// RUN: %clang --target=loongarch64 -mfrecipe -fsyntax-only %s -### 2>&1 | \ | ||
// RUN: FileCheck %s --check-prefix=CC1-FRECIPE | ||
// RUN: %clang --target=loongarch64 -mno-frecipe -fsyntax-only %s -### 2>&1 | \ | ||
// RUN: FileCheck %s --check-prefix=CC1-NO-FRECIPE | ||
// RUN: %clang --target=loongarch64 -mno-frecipe -mfrecipe -fsyntax-only %s -### 2>&1 | \ | ||
// RUN: FileCheck %s --check-prefix=CC1-FRECIPE | ||
// RUN: %clang --target=loongarch64 -mfrecipe -mno-frecipe -fsyntax-only %s -### 2>&1 | \ | ||
// RUN: FileCheck %s --check-prefix=CC1-NO-FRECIPE | ||
|
||
// RUN: %clang --target=loongarch64 -mfrecipe -S -emit-llvm %s -o - | \ | ||
// RUN: FileCheck %s --check-prefix=IR-FRECIPE | ||
// RUN: %clang --target=loongarch64 -mno-frecipe -S -emit-llvm %s -o - | \ | ||
// RUN: FileCheck %s --check-prefix=IR-NO-FRECIPE | ||
// RUN: %clang --target=loongarch64 -mno-frecipe -mfrecipe -S -emit-llvm %s -o - | \ | ||
// RUN: FileCheck %s --check-prefix=IR-FRECIPE | ||
// RUN: %clang --target=loongarch64 -mfrecipe -mno-frecipe -S -emit-llvm %s -o - | \ | ||
// RUN: FileCheck %s --check-prefix=IR-NO-FRECIPE | ||
|
||
|
||
// CC1-FRECIPE: "-target-feature" "+frecipe" | ||
// CC1-NO-FRECIPE: "-target-feature" "-frecipe" | ||
|
||
// IR-FRECIPE: attributes #[[#]] ={{.*}}"target-features"="{{(.*,)?}}+frecipe{{(,.*)?}}" | ||
// IR-NO-FRECIPE: attributes #[[#]] ={{.*}}"target-features"="{{(.*,)?}}-frecipe{{(,.*)?}}" | ||
|
||
int foo(void) { | ||
return 42; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
; RUN: llc --mtriple=loongarch32 --mattr=+f,-d,-frecipe < %s | FileCheck %s --check-prefix=LA32F | ||
; RUN: llc --mtriple=loongarch32 --mattr=+f,-d,+frecipe < %s | FileCheck %s --check-prefix=LA32F-FRECIPE | ||
; RUN: llc --mtriple=loongarch64 --mattr=+d,-frecipe < %s | FileCheck %s --check-prefix=LA64D | ||
; RUN: llc --mtriple=loongarch64 --mattr=+d,+frecipe < %s | FileCheck %s --check-prefix=LA64D-FRECIPE | ||
|
||
;; Exercise the 'fdiv' LLVM IR: https://llvm.org/docs/LangRef.html#fdiv-instruction | ||
|
||
define float @fdiv_s(float %x, float %y) { | ||
; LA32F-LABEL: fdiv_s: | ||
; LA32F: # %bb.0: | ||
; LA32F-NEXT: fdiv.s $fa0, $fa0, $fa1 | ||
; LA32F-NEXT: ret | ||
; | ||
; LA32F-FRECIPE-LABEL: fdiv_s: | ||
; LA32F-FRECIPE: # %bb.0: | ||
; LA32F-FRECIPE-NEXT: frecipe.s $fa2, $fa1 | ||
; LA32F-FRECIPE-NEXT: fmul.s $fa3, $fa0, $fa2 | ||
; LA32F-FRECIPE-NEXT: fnmsub.s $fa0, $fa1, $fa3, $fa0 | ||
; LA32F-FRECIPE-NEXT: fmadd.s $fa0, $fa2, $fa0, $fa3 | ||
; LA32F-FRECIPE-NEXT: ret | ||
; | ||
; LA64D-LABEL: fdiv_s: | ||
; LA64D: # %bb.0: | ||
; LA64D-NEXT: fdiv.s $fa0, $fa0, $fa1 | ||
; LA64D-NEXT: ret | ||
; | ||
; LA64D-FRECIPE-LABEL: fdiv_s: | ||
; LA64D-FRECIPE: # %bb.0: | ||
; LA64D-FRECIPE-NEXT: frecipe.s $fa2, $fa1 | ||
; LA64D-FRECIPE-NEXT: fmul.s $fa3, $fa0, $fa2 | ||
; LA64D-FRECIPE-NEXT: fnmsub.s $fa0, $fa1, $fa3, $fa0 | ||
; LA64D-FRECIPE-NEXT: fmadd.s $fa0, $fa2, $fa0, $fa3 | ||
; LA64D-FRECIPE-NEXT: ret | ||
%div = fdiv fast float %x, %y | ||
ret float %div | ||
} | ||
|
||
define double @fdiv_d(double %x, double %y) { | ||
; LA32F-LABEL: fdiv_d: | ||
; LA32F: # %bb.0: | ||
; LA32F-NEXT: addi.w $sp, $sp, -16 | ||
; LA32F-NEXT: .cfi_def_cfa_offset 16 | ||
; LA32F-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill | ||
; LA32F-NEXT: .cfi_offset 1, -4 | ||
; LA32F-NEXT: bl %plt(__divdf3) | ||
; LA32F-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload | ||
; LA32F-NEXT: addi.w $sp, $sp, 16 | ||
; LA32F-NEXT: ret | ||
; | ||
; LA32F-FRECIPE-LABEL: fdiv_d: | ||
; LA32F-FRECIPE: # %bb.0: | ||
; LA32F-FRECIPE-NEXT: addi.w $sp, $sp, -16 | ||
; LA32F-FRECIPE-NEXT: .cfi_def_cfa_offset 16 | ||
; LA32F-FRECIPE-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill | ||
; LA32F-FRECIPE-NEXT: .cfi_offset 1, -4 | ||
; LA32F-FRECIPE-NEXT: bl %plt(__divdf3) | ||
; LA32F-FRECIPE-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload | ||
; LA32F-FRECIPE-NEXT: addi.w $sp, $sp, 16 | ||
; LA32F-FRECIPE-NEXT: ret | ||
; | ||
; LA64D-LABEL: fdiv_d: | ||
; LA64D: # %bb.0: | ||
; LA64D-NEXT: fdiv.d $fa0, $fa0, $fa1 | ||
; LA64D-NEXT: ret | ||
; | ||
; LA64D-FRECIPE-LABEL: fdiv_d: | ||
; LA64D-FRECIPE: # %bb.0: | ||
; LA64D-FRECIPE-NEXT: pcalau12i $a0, %pc_hi20(.LCPI1_0) | ||
; LA64D-FRECIPE-NEXT: fld.d $fa2, $a0, %pc_lo12(.LCPI1_0) | ||
; LA64D-FRECIPE-NEXT: frecipe.d $fa3, $fa1 | ||
; LA64D-FRECIPE-NEXT: fmadd.d $fa2, $fa1, $fa3, $fa2 | ||
; LA64D-FRECIPE-NEXT: fnmsub.d $fa2, $fa2, $fa3, $fa3 | ||
; LA64D-FRECIPE-NEXT: fmul.d $fa3, $fa0, $fa2 | ||
; LA64D-FRECIPE-NEXT: fnmsub.d $fa0, $fa1, $fa3, $fa0 | ||
; LA64D-FRECIPE-NEXT: fmadd.d $fa0, $fa2, $fa0, $fa3 | ||
; LA64D-FRECIPE-NEXT: ret | ||
%div = fdiv fast double %x, %y | ||
ret double %div | ||
} |
Oops, something went wrong.