Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[X86][BF16] Enable __bf16 for x86 targets.
X86 psABI has updated to support __bf16 type, the ABI of which is the same as FP16. See https://discourse.llvm.org/t/patch-add-optional-bfloat16-support/63149 Reviewed By: pengfei Differential Revision: https://reviews.llvm.org/D130964 (cherry picked from commit e4888a3)
- Loading branch information
1 parent
54f3f97
commit fa0ff57
Showing
9 changed files
with
326 additions
and
7 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
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,149 @@ | ||
// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -target-feature +sse2 < %s | FileCheck %s --check-prefixes=CHECK | ||
|
||
struct bfloat1 { | ||
__bf16 a; | ||
}; | ||
|
||
struct bfloat1 h1(__bf16 a) { | ||
// CHECK: define{{.*}}bfloat @ | ||
struct bfloat1 x; | ||
x.a = a; | ||
return x; | ||
} | ||
|
||
struct bfloat2 { | ||
__bf16 a; | ||
__bf16 b; | ||
}; | ||
|
||
struct bfloat2 h2(__bf16 a, __bf16 b) { | ||
// CHECK: define{{.*}}<2 x bfloat> @ | ||
struct bfloat2 x; | ||
x.a = a; | ||
x.b = b; | ||
return x; | ||
} | ||
|
||
struct bfloat3 { | ||
__bf16 a; | ||
__bf16 b; | ||
__bf16 c; | ||
}; | ||
|
||
struct bfloat3 h3(__bf16 a, __bf16 b, __bf16 c) { | ||
// CHECK: define{{.*}}<4 x bfloat> @ | ||
struct bfloat3 x; | ||
x.a = a; | ||
x.b = b; | ||
x.c = c; | ||
return x; | ||
} | ||
|
||
struct bfloat4 { | ||
__bf16 a; | ||
__bf16 b; | ||
__bf16 c; | ||
__bf16 d; | ||
}; | ||
|
||
struct bfloat4 h4(__bf16 a, __bf16 b, __bf16 c, __bf16 d) { | ||
// CHECK: define{{.*}}<4 x bfloat> @ | ||
struct bfloat4 x; | ||
x.a = a; | ||
x.b = b; | ||
x.c = c; | ||
x.d = d; | ||
return x; | ||
} | ||
|
||
struct floatbfloat { | ||
float a; | ||
__bf16 b; | ||
}; | ||
|
||
struct floatbfloat fh(float a, __bf16 b) { | ||
// CHECK: define{{.*}}<4 x half> @ | ||
struct floatbfloat x; | ||
x.a = a; | ||
x.b = b; | ||
return x; | ||
} | ||
|
||
struct floatbfloat2 { | ||
float a; | ||
__bf16 b; | ||
__bf16 c; | ||
}; | ||
|
||
struct floatbfloat2 fh2(float a, __bf16 b, __bf16 c) { | ||
// CHECK: define{{.*}}<4 x half> @ | ||
struct floatbfloat2 x; | ||
x.a = a; | ||
x.b = b; | ||
x.c = c; | ||
return x; | ||
} | ||
|
||
struct bfloatfloat { | ||
__bf16 a; | ||
float b; | ||
}; | ||
|
||
struct bfloatfloat hf(__bf16 a, float b) { | ||
// CHECK: define{{.*}}<4 x half> @ | ||
struct bfloatfloat x; | ||
x.a = a; | ||
x.b = b; | ||
return x; | ||
} | ||
|
||
struct bfloat2float { | ||
__bf16 a; | ||
__bf16 b; | ||
float c; | ||
}; | ||
|
||
struct bfloat2float h2f(__bf16 a, __bf16 b, float c) { | ||
// CHECK: define{{.*}}<4 x bfloat> @ | ||
struct bfloat2float x; | ||
x.a = a; | ||
x.b = b; | ||
x.c = c; | ||
return x; | ||
} | ||
|
||
struct floatbfloat3 { | ||
float a; | ||
__bf16 b; | ||
__bf16 c; | ||
__bf16 d; | ||
}; | ||
|
||
struct floatbfloat3 fh3(float a, __bf16 b, __bf16 c, __bf16 d) { | ||
// CHECK: define{{.*}}{ <4 x half>, bfloat } @ | ||
struct floatbfloat3 x; | ||
x.a = a; | ||
x.b = b; | ||
x.c = c; | ||
x.d = d; | ||
return x; | ||
} | ||
|
||
struct bfloat5 { | ||
__bf16 a; | ||
__bf16 b; | ||
__bf16 c; | ||
__bf16 d; | ||
__bf16 e; | ||
}; | ||
|
||
struct bfloat5 h5(__bf16 a, __bf16 b, __bf16 c, __bf16 d, __bf16 e) { | ||
// CHECK: define{{.*}}{ <4 x bfloat>, bfloat } @ | ||
struct bfloat5 x; | ||
x.a = a; | ||
x.b = b; | ||
x.c = c; | ||
x.d = d; | ||
x.e = e; | ||
return x; | ||
} |
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,149 @@ | ||
// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -target-feature +sse2 < %s | FileCheck %s --check-prefixes=CHECK | ||
|
||
struct bfloat1 { | ||
__bf16 a; | ||
}; | ||
|
||
struct bfloat1 h1(__bf16 a) { | ||
// CHECK: define{{.*}}bfloat @ | ||
struct bfloat1 x; | ||
x.a = a; | ||
return x; | ||
} | ||
|
||
struct bfloat2 { | ||
__bf16 a; | ||
__bf16 b; | ||
}; | ||
|
||
struct bfloat2 h2(__bf16 a, __bf16 b) { | ||
// CHECK: define{{.*}}<2 x bfloat> @ | ||
struct bfloat2 x; | ||
x.a = a; | ||
x.b = b; | ||
return x; | ||
} | ||
|
||
struct bfloat3 { | ||
__bf16 a; | ||
__bf16 b; | ||
__bf16 c; | ||
}; | ||
|
||
struct bfloat3 h3(__bf16 a, __bf16 b, __bf16 c) { | ||
// CHECK: define{{.*}}<4 x bfloat> @ | ||
struct bfloat3 x; | ||
x.a = a; | ||
x.b = b; | ||
x.c = c; | ||
return x; | ||
} | ||
|
||
struct bfloat4 { | ||
__bf16 a; | ||
__bf16 b; | ||
__bf16 c; | ||
__bf16 d; | ||
}; | ||
|
||
struct bfloat4 h4(__bf16 a, __bf16 b, __bf16 c, __bf16 d) { | ||
// CHECK: define{{.*}}<4 x bfloat> @ | ||
struct bfloat4 x; | ||
x.a = a; | ||
x.b = b; | ||
x.c = c; | ||
x.d = d; | ||
return x; | ||
} | ||
|
||
struct floatbfloat { | ||
float a; | ||
__bf16 b; | ||
}; | ||
|
||
struct floatbfloat fh(float a, __bf16 b) { | ||
// CHECK: define{{.*}}<4 x half> @ | ||
struct floatbfloat x; | ||
x.a = a; | ||
x.b = b; | ||
return x; | ||
} | ||
|
||
struct floatbfloat2 { | ||
float a; | ||
__bf16 b; | ||
__bf16 c; | ||
}; | ||
|
||
struct floatbfloat2 fh2(float a, __bf16 b, __bf16 c) { | ||
// CHECK: define{{.*}}<4 x half> @ | ||
struct floatbfloat2 x; | ||
x.a = a; | ||
x.b = b; | ||
x.c = c; | ||
return x; | ||
} | ||
|
||
struct bfloatfloat { | ||
__bf16 a; | ||
float b; | ||
}; | ||
|
||
struct bfloatfloat hf(__bf16 a, float b) { | ||
// CHECK: define{{.*}}<4 x half> @ | ||
struct bfloatfloat x; | ||
x.a = a; | ||
x.b = b; | ||
return x; | ||
} | ||
|
||
struct bfloat2float { | ||
__bf16 a; | ||
__bf16 b; | ||
float c; | ||
}; | ||
|
||
struct bfloat2float h2f(__bf16 a, __bf16 b, float c) { | ||
// CHECK: define{{.*}}<4 x bfloat> @ | ||
struct bfloat2float x; | ||
x.a = a; | ||
x.b = b; | ||
x.c = c; | ||
return x; | ||
} | ||
|
||
struct floatbfloat3 { | ||
float a; | ||
__bf16 b; | ||
__bf16 c; | ||
__bf16 d; | ||
}; | ||
|
||
struct floatbfloat3 fh3(float a, __bf16 b, __bf16 c, __bf16 d) { | ||
// CHECK: define{{.*}}{ <4 x half>, bfloat } @ | ||
struct floatbfloat3 x; | ||
x.a = a; | ||
x.b = b; | ||
x.c = c; | ||
x.d = d; | ||
return x; | ||
} | ||
|
||
struct bfloat5 { | ||
__bf16 a; | ||
__bf16 b; | ||
__bf16 c; | ||
__bf16 d; | ||
__bf16 e; | ||
}; | ||
|
||
struct bfloat5 h5(__bf16 a, __bf16 b, __bf16 c, __bf16 d, __bf16 e) { | ||
// CHECK: define{{.*}}{ <4 x bfloat>, bfloat } @ | ||
struct bfloat5 x; | ||
x.a = a; | ||
x.b = b; | ||
x.c = c; | ||
x.d = d; | ||
x.e = e; | ||
return x; | ||
} |
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,5 @@ | ||
// RUN: %clang_cc1 -triple i386-unknown-unknown -target-feature +sse2 -emit-llvm -o - %s | FileCheck %s | ||
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-feature +sse2 -emit-llvm -o - %s | FileCheck %s | ||
|
||
// CHECK: define {{.*}}void @_Z3foou6__bf16(bfloat noundef %b) | ||
void foo(__bf16 b) {} |
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
Oops, something went wrong.