Implement support for PTX call instruction

This commit is contained in:
Andrzej Janik 2020-09-06 21:38:01 +02:00
parent bbb3a6c5cb
commit 76afbeba63
20 changed files with 1691 additions and 887 deletions

View file

@ -75,3 +75,9 @@ CUDA <-> L0
* context ~= context (1.0+)
* graph ~= command list
* module ~= module
IGC
---
* IGC is extremely brittle and segfaults on fairly innocent code:
* OpBitcast of pointer to uint
* OpCopyMemory of alloca'd variable

View file

@ -51,23 +51,34 @@ pub struct Module<'a> {
pub functions: Vec<ParsedFunction<'a>>,
}
pub enum FunctionHeader<'a, P: ArgParams> {
Func(Vec<Argument<P>>, P::ID),
Kernel(&'a str),
pub enum MethodDecl<'a, P: ArgParams> {
Func(Vec<FnArgument<P>>, P::ID, Vec<FnArgument<P>>),
Kernel(&'a str, Vec<KernelArgument<P>>),
}
pub struct Function<'a, P: ArgParams, S> {
pub func_directive: FunctionHeader<'a, P>,
pub args: Vec<Argument<P>>,
pub func_directive: MethodDecl<'a, P>,
pub body: Option<Vec<S>>,
}
pub type ParsedFunction<'a> = Function<'a, ParsedArgParams<'a>, Statement<ParsedArgParams<'a>>>;
#[derive(Default)]
pub struct Argument<P: ArgParams> {
pub struct FnArgument<P: ArgParams> {
pub base: KernelArgument<P>,
pub state_space: FnArgStateSpace,
}
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum FnArgStateSpace {
Reg,
Param,
}
#[derive(Default, Copy, Clone)]
pub struct KernelArgument<P: ArgParams> {
pub name: P::ID,
pub a_type: ScalarType,
// TODO: turn length into part of type definition
pub length: u32,
}
@ -222,28 +233,26 @@ pub enum Instruction<P: ArgParams> {
Shl(ShlType, Arg3<P>),
St(StData, Arg2St<P>),
Ret(RetData),
Call(CallData, ArgCall<P>),
Call(CallInst<P>),
Abs(AbsDetails, Arg2<P>),
}
pub struct CallData {
pub uniform: bool,
}
pub struct AbsDetails {
pub flush_to_zero: bool,
pub typ: ScalarType,
}
pub struct ArgCall<P: ArgParams> {
pub struct CallInst<P: ArgParams> {
pub uniform: bool,
pub ret_params: Vec<P::ID>,
pub func: P::ID,
pub param_list: Vec<P::ID>,
pub param_list: Vec<P::CallOperand>,
}
pub trait ArgParams {
type ID;
type Operand;
type CallOperand;
type MovOperand;
}
@ -254,6 +263,7 @@ pub struct ParsedArgParams<'a> {
impl<'a> ArgParams for ParsedArgParams<'a> {
type ID = &'a str;
type Operand = Operand<&'a str>;
type CallOperand = CallOperand<&'a str>;
type MovOperand = MovOperand<&'a str>;
}
@ -304,6 +314,12 @@ pub enum Operand<ID> {
Imm(i128),
}
#[derive(Copy, Clone)]
pub enum CallOperand<ID> {
Reg(ID),
Imm(i128),
}
pub enum MovOperand<ID> {
Op(Operand<ID>),
Vec(String, String),

View file

@ -202,8 +202,7 @@ AddressSize = {
Function: ast::Function<'input, ast::ParsedArgParams<'input>, ast::Statement<ast::ParsedArgParams<'input>>> = {
LinkingDirective*
<func_directive:FunctionHeader>
<args:Arguments>
<func_directive:MethodDecl>
<body:FunctionBody> => ast::Function{<>}
};
@ -213,24 +212,43 @@ LinkingDirective = {
".weak"
};
FunctionHeader: ast::FunctionHeader<'input, ast::ParsedArgParams<'input>> = {
".entry" <name:ExtendedID> => ast::FunctionHeader::Kernel(name),
".func" <args:Arguments?> <name:ExtendedID> => ast::FunctionHeader::Func(args.unwrap_or_else(|| Vec::new()), name)
MethodDecl: ast::MethodDecl<'input, ast::ParsedArgParams<'input>> = {
".entry" <name:ExtendedID> <params:KernelArguments> => ast::MethodDecl::Kernel(name, params),
".func" <ret_vals:FnArguments?> <name:ExtendedID> <params:FnArguments> => ast::MethodDecl::Func(ret_vals.unwrap_or_else(|| Vec::new()), name, params)
};
Arguments: Vec<ast::Argument<ast::ParsedArgParams<'input>>> = {
"(" <args:Comma<FunctionInput>> ")" => args
}
KernelArguments: Vec<ast::KernelArgument<ast::ParsedArgParams<'input>>> = {
"(" <args:Comma<KernelInput>> ")" => args
};
FnArguments: Vec<ast::FnArgument<ast::ParsedArgParams<'input>>> = {
"(" <args:Comma<FnInput>> ")" => args
};
FnInput: ast::FnArgument<ast::ParsedArgParams<'input>> = {
".reg" <_type:ScalarType> <name:ExtendedID> => {
ast::FnArgument {
base: ast::KernelArgument {a_type: _type, name: name, length: 1 },
state_space: ast::FnArgStateSpace::Reg,
}
},
<p:KernelInput> => {
ast::FnArgument {
base: p,
state_space: ast::FnArgStateSpace::Param,
}
}
};
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parameter-state-space
FunctionInput: ast::Argument<ast::ParsedArgParams<'input>> = {
KernelInput: ast::KernelArgument<ast::ParsedArgParams<'input>> = {
".param" <_type:ScalarType> <name:ExtendedID> => {
ast::Argument {a_type: _type, name: name, length: 1 }
ast::KernelArgument {a_type: _type, name: name, length: 1 }
},
".param" <a_type:ScalarType> <name:ExtendedID> "[" <length:Num> "]" => {
let length = length.parse::<u32>();
let length = length.unwrap_with(errors);
ast::Argument { a_type: a_type, name: name, length: length }
ast::KernelArgument { a_type: a_type, name: name, length: length }
}
};
@ -856,7 +874,10 @@ CvtaSize: ast::CvtaSize = {
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#control-flow-instructions-call
InstCall: ast::Instruction<ast::ParsedArgParams<'input>> = {
"call" <u:".uni"?> <a:ArgCall> => ast::Instruction::Call(ast::CallData { uniform: u.is_some() }, a)
"call" <u:".uni"?> <args:ArgCall> => {
let (ret_params, func, param_list) = args;
ast::Instruction::Call(ast::CallInst { uniform: u.is_some(), ret_params, func, param_list })
}
};
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#integer-arithmetic-instructions-abs
@ -900,6 +921,15 @@ Operand: ast::Operand<&'input str> = {
}
};
CallOperand: ast::CallOperand<&'input str> = {
<r:ExtendedID> => ast::CallOperand::Reg(r),
<o:Num> => {
let offset = o.parse::<i128>();
let offset = offset.unwrap_with(errors);
ast::CallOperand::Imm(offset)
}
};
MovOperand: ast::MovOperand<&'input str> = {
<o:Operand> => ast::MovOperand::Op(o),
<o:VectorOperand> => {
@ -938,10 +968,12 @@ Arg5: ast::Arg5<ast::ParsedArgParams<'input>> = {
<dst1:ExtendedID> <dst2:OptionalDst?> "," <src1:Operand> "," <src2:Operand> "," "!"? <src3:Operand> => ast::Arg5{<>}
};
ArgCall: ast::ArgCall<ast::ParsedArgParams<'input>> = {
"(" <ret_params:Comma<ExtendedID>> ")" "," <func:ExtendedID> "," "(" <param_list:Comma<ExtendedID>> ")" => ast::ArgCall{<>},
<func:ExtendedID> "," "(" <param_list:Comma<ExtendedID>> ")" => ast::ArgCall{ret_params: Vec::new(), func, param_list},
<func:ExtendedID> => ast::ArgCall{ret_params: Vec::new(), func, param_list: Vec::new()},
ArgCall: (Vec<&'input str>, &'input str, Vec<ast::CallOperand<&'input str>>) = {
"(" <ret_params:Comma<ExtendedID>> ")" "," <func:ExtendedID> "," "(" <param_list:Comma<CallOperand>> ")" => {
(ret_params, func, param_list)
},
<func:ExtendedID> "," "(" <param_list:Comma<CallOperand>> ")" => (Vec::new(), func, param_list),
<func:ExtendedID> => (Vec::new(), func, Vec::<ast::CallOperand<_>>::new()),
};
OptionalDst: &'input str = {

View file

@ -1,38 +1,46 @@
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%1 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %5 "add"
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%4 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%_ptr_Generic_ulong = OpTypePointer Generic %ulong
%ulong_1 = OpConstant %ulong 1
%5 = OpFunction %void None %4
%6 = OpFunctionParameter %ulong
%7 = OpFunctionParameter %ulong
%21 = OpLabel
%8 = OpVariable %_ptr_Function_ulong Function
%9 = OpVariable %_ptr_Function_ulong Function
%10 = OpVariable %_ptr_Function_ulong Function
%11 = OpVariable %_ptr_Function_ulong Function
OpStore %8 %6
OpStore %9 %7
%12 = OpLoad %ulong %8
%19 = OpConvertUToPtr %_ptr_Generic_ulong %12
%13 = OpLoad %ulong %19
OpStore %10 %13
%14 = OpLoad %ulong %10
%15 = OpIAdd %ulong %14 %ulong_1
OpStore %11 %15
%16 = OpLoad %ulong %9
%17 = OpLoad %ulong %11
%20 = OpConvertUToPtr %_ptr_Generic_ulong %16
OpStore %20 %17
OpReturn
OpFunctionEnd
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%25 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %1 "add"
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%28 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%_ptr_Generic_ulong = OpTypePointer Generic %ulong
%ulong_1 = OpConstant %ulong 1
%1 = OpFunction %void None %28
%8 = OpFunctionParameter %ulong
%9 = OpFunctionParameter %ulong
%23 = OpLabel
%2 = OpVariable %_ptr_Function_ulong Function
%3 = OpVariable %_ptr_Function_ulong Function
%4 = OpVariable %_ptr_Function_ulong Function
%5 = OpVariable %_ptr_Function_ulong Function
%6 = OpVariable %_ptr_Function_ulong Function
%7 = OpVariable %_ptr_Function_ulong Function
OpStore %2 %8
OpStore %3 %9
%11 = OpLoad %ulong %2
%10 = OpCopyObject %ulong %11
OpStore %4 %10
%13 = OpLoad %ulong %3
%12 = OpCopyObject %ulong %13
OpStore %5 %12
%15 = OpLoad %ulong %4
%21 = OpConvertUToPtr %_ptr_Generic_ulong %15
%14 = OpLoad %ulong %21
OpStore %6 %14
%17 = OpLoad %ulong %6
%16 = OpIAdd %ulong %17 %ulong_1
OpStore %7 %16
%18 = OpLoad %ulong %5
%19 = OpLoad %ulong %7
%22 = OpConvertUToPtr %_ptr_Generic_ulong %18
OpStore %22 %19
OpReturn
OpFunctionEnd

View file

@ -1,44 +1,51 @@
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%1 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %5 "block"
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%4 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%_ptr_Generic_ulong = OpTypePointer Generic %ulong
%ulong_1 = OpConstant %ulong 1
%ulong_1_0 = OpConstant %ulong 1
%5 = OpFunction %void None %4
%6 = OpFunctionParameter %ulong
%7 = OpFunctionParameter %ulong
%25 = OpLabel
%8 = OpVariable %_ptr_Function_ulong Function
%9 = OpVariable %_ptr_Function_ulong Function
%10 = OpVariable %_ptr_Function_ulong Function
%11 = OpVariable %_ptr_Function_ulong Function
OpStore %8 %6
OpStore %9 %7
%14 = OpLoad %ulong %8
%23 = OpConvertUToPtr %_ptr_Generic_ulong %14
%13 = OpLoad %ulong %23
OpStore %10 %13
%16 = OpLoad %ulong %10
%15 = OpIAdd %ulong %16 %ulong_1
OpStore %11 %15
%12 = OpVariable %_ptr_Function_ulong Function
%18 = OpLoad %ulong %12
%17 = OpIAdd %ulong %18 %ulong_1_0
OpStore %12 %17
%19 = OpLoad %ulong %9
%20 = OpLoad %ulong %11
%24 = OpConvertUToPtr %_ptr_Generic_ulong %19
OpStore %24 %20
OpReturn
OpFunctionEnd
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%29 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %1 "block"
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%32 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%_ptr_Generic_ulong = OpTypePointer Generic %ulong
%ulong_1 = OpConstant %ulong 1
%ulong_1_0 = OpConstant %ulong 1
%1 = OpFunction %void None %32
%9 = OpFunctionParameter %ulong
%10 = OpFunctionParameter %ulong
%27 = OpLabel
%2 = OpVariable %_ptr_Function_ulong Function
%3 = OpVariable %_ptr_Function_ulong Function
%4 = OpVariable %_ptr_Function_ulong Function
%5 = OpVariable %_ptr_Function_ulong Function
%6 = OpVariable %_ptr_Function_ulong Function
%7 = OpVariable %_ptr_Function_ulong Function
%8 = OpVariable %_ptr_Function_ulong Function
OpStore %2 %9
OpStore %3 %10
%12 = OpLoad %ulong %2
%11 = OpCopyObject %ulong %12
OpStore %4 %11
%14 = OpLoad %ulong %3
%13 = OpCopyObject %ulong %14
OpStore %5 %13
%16 = OpLoad %ulong %4
%25 = OpConvertUToPtr %_ptr_Generic_ulong %16
%15 = OpLoad %ulong %25
OpStore %6 %15
%18 = OpLoad %ulong %6
%17 = OpIAdd %ulong %18 %ulong_1
OpStore %7 %17
%20 = OpLoad %ulong %8
%19 = OpIAdd %ulong %20 %ulong_1_0
OpStore %8 %19
%21 = OpLoad %ulong %5
%22 = OpLoad %ulong %7
%26 = OpConvertUToPtr %_ptr_Generic_ulong %21
OpStore %26 %22
OpReturn
OpFunctionEnd

View file

@ -1,49 +1,56 @@
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%1 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %5 "bra"
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%4 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%_ptr_Generic_ulong = OpTypePointer Generic %ulong
%ulong_1 = OpConstant %ulong 1
%ulong_2 = OpConstant %ulong 2
%5 = OpFunction %void None %4
%6 = OpFunctionParameter %ulong
%7 = OpFunctionParameter %ulong
%27 = OpLabel
%11 = OpVariable %_ptr_Function_ulong Function
%12 = OpVariable %_ptr_Function_ulong Function
%13 = OpVariable %_ptr_Function_ulong Function
%14 = OpVariable %_ptr_Function_ulong Function
OpStore %11 %6
OpStore %12 %7
%16 = OpLoad %ulong %11
%25 = OpConvertUToPtr %_ptr_Generic_ulong %16
%15 = OpLoad %ulong %25
OpStore %13 %15
OpBranch %8
%8 = OpLabel
%18 = OpLoad %ulong %13
%17 = OpIAdd %ulong %18 %ulong_1
OpStore %14 %17
OpBranch %10
%30 = OpLabel
%20 = OpLoad %ulong %13
%19 = OpIAdd %ulong %20 %ulong_2
OpStore %14 %19
OpBranch %10
%10 = OpLabel
%21 = OpLoad %ulong %12
%22 = OpLoad %ulong %14
%26 = OpConvertUToPtr %_ptr_Generic_ulong %21
OpStore %26 %22
OpReturn
OpFunctionEnd
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%31 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %1 "bra"
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%34 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%_ptr_Generic_ulong = OpTypePointer Generic %ulong
%ulong_1 = OpConstant %ulong 1
%ulong_2 = OpConstant %ulong 2
%1 = OpFunction %void None %34
%11 = OpFunctionParameter %ulong
%12 = OpFunctionParameter %ulong
%29 = OpLabel
%2 = OpVariable %_ptr_Function_ulong Function
%3 = OpVariable %_ptr_Function_ulong Function
%7 = OpVariable %_ptr_Function_ulong Function
%8 = OpVariable %_ptr_Function_ulong Function
%9 = OpVariable %_ptr_Function_ulong Function
%10 = OpVariable %_ptr_Function_ulong Function
OpStore %2 %11
OpStore %3 %12
%14 = OpLoad %ulong %2
%13 = OpCopyObject %ulong %14
OpStore %7 %13
%16 = OpLoad %ulong %3
%15 = OpCopyObject %ulong %16
OpStore %8 %15
%18 = OpLoad %ulong %7
%27 = OpConvertUToPtr %_ptr_Generic_ulong %18
%17 = OpLoad %ulong %27
OpStore %9 %17
OpBranch %4
%4 = OpLabel
%20 = OpLoad %ulong %9
%19 = OpIAdd %ulong %20 %ulong_1
OpStore %10 %19
OpBranch %6
%37 = OpLabel
%22 = OpLoad %ulong %9
%21 = OpIAdd %ulong %22 %ulong_2
OpStore %10 %21
OpBranch %6
%6 = OpLabel
%23 = OpLoad %ulong %8
%24 = OpLoad %ulong %10
%28 = OpConvertUToPtr %_ptr_Generic_ulong %23
OpStore %28 %24
OpReturn
OpFunctionEnd

View file

@ -0,0 +1,38 @@
.version 6.5
.target sm_30
.address_size 64
.func (.param.u64 output) incr (.param.u64 input);
.visible .entry call(
.param .u64 input,
.param .u64 output
)
{
.reg .u64 in_addr;
.reg .u64 out_addr;
.reg .u64 temp;
ld.param.u64 in_addr, [input];
ld.param.u64 out_addr, [output];
ld.global.u64 temp, [in_addr];
.param.u64 incr_in;
.param.u64 incr_out;
st.param.b64 [incr_in], temp;
call (incr_out), incr, (incr_in);
ld.param.u64 temp, [incr_out];
st.global.u64 [out_addr], temp;
ret;
}
.func (.param .u64 output) incr(
.param .u64 input
)
{
.reg .u64 temp;
ld.param.u64 temp, [input];
add.u64 temp, temp, 1;
st.param.u64 [output], temp;
ret;
}

View file

@ -0,0 +1,73 @@
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%45 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %4 "call"
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%48 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%_ptr_CrossWorkgroup_ulong = OpTypePointer CrossWorkgroup %ulong
%51 = OpTypeFunction %ulong %ulong
%ulong_1 = OpConstant %ulong 1
%4 = OpFunction %void None %48
%12 = OpFunctionParameter %ulong
%13 = OpFunctionParameter %ulong
%30 = OpLabel
%5 = OpVariable %_ptr_Function_ulong Function
%6 = OpVariable %_ptr_Function_ulong Function
%7 = OpVariable %_ptr_Function_ulong Function
%8 = OpVariable %_ptr_Function_ulong Function
%9 = OpVariable %_ptr_Function_ulong Function
%10 = OpVariable %_ptr_Function_ulong Function
%11 = OpVariable %_ptr_Function_ulong Function
OpStore %5 %12
OpStore %6 %13
%15 = OpLoad %ulong %5
%14 = OpCopyObject %ulong %15
OpStore %7 %14
%17 = OpLoad %ulong %6
%16 = OpCopyObject %ulong %17
OpStore %8 %16
%19 = OpLoad %ulong %7
%28 = OpConvertUToPtr %_ptr_CrossWorkgroup_ulong %19
%18 = OpLoad %ulong %28
OpStore %9 %18
%21 = OpLoad %ulong %9
%20 = OpCopyObject %ulong %21
OpStore %10 %20
%23 = OpLoad %ulong %10
%22 = OpFunctionCall %ulong %1 %23
OpStore %11 %22
%25 = OpLoad %ulong %11
%24 = OpCopyObject %ulong %25
OpStore %9 %24
%26 = OpLoad %ulong %8
%27 = OpLoad %ulong %9
%29 = OpConvertUToPtr %_ptr_CrossWorkgroup_ulong %26
OpStore %29 %27
OpReturn
OpFunctionEnd
%1 = OpFunction %ulong None %51
%34 = OpFunctionParameter %ulong
%43 = OpLabel
%32 = OpVariable %_ptr_Function_ulong Function
%31 = OpVariable %_ptr_Function_ulong Function
%33 = OpVariable %_ptr_Function_ulong Function
OpStore %32 %34
%36 = OpLoad %ulong %32
%35 = OpCopyObject %ulong %36
OpStore %33 %35
%38 = OpLoad %ulong %33
%37 = OpIAdd %ulong %38 %ulong_1
OpStore %33 %37
%40 = OpLoad %ulong %33
%39 = OpCopyObject %ulong %40
OpStore %31 %39
%41 = OpLoad %ulong %31
OpReturnValue %41
OpFunctionEnd

View file

@ -1,43 +1,51 @@
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%1 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %5 "cvt_sat_s_u"
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%4 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%uint = OpTypeInt 32 0
%_ptr_Function_uint = OpTypePointer Function %uint
%_ptr_Generic_uint = OpTypePointer Generic %uint
%5 = OpFunction %void None %4
%6 = OpFunctionParameter %ulong
%7 = OpFunctionParameter %ulong
%23 = OpLabel
%8 = OpVariable %_ptr_Function_ulong Function
%9 = OpVariable %_ptr_Function_ulong Function
%10 = OpVariable %_ptr_Function_uint Function
%11 = OpVariable %_ptr_Function_uint Function
%12 = OpVariable %_ptr_Function_uint Function
OpStore %8 %6
OpStore %9 %7
%14 = OpLoad %ulong %8
%21 = OpConvertUToPtr %_ptr_Generic_uint %14
%13 = OpLoad %uint %21
OpStore %10 %13
%16 = OpLoad %uint %10
%15 = OpSatConvertSToU %uint %16
OpStore %11 %15
%18 = OpLoad %uint %11
%17 = OpBitcast %uint %18
OpStore %12 %17
%19 = OpLoad %ulong %9
%20 = OpLoad %uint %12
%22 = OpConvertUToPtr %_ptr_Generic_uint %19
OpStore %22 %20
OpReturn
OpFunctionEnd
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%27 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %1 "cvt_sat_s_u"
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%30 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%uint = OpTypeInt 32 0
%_ptr_Function_uint = OpTypePointer Function %uint
%_ptr_Generic_uint = OpTypePointer Generic %uint
%1 = OpFunction %void None %30
%9 = OpFunctionParameter %ulong
%10 = OpFunctionParameter %ulong
%25 = OpLabel
%2 = OpVariable %_ptr_Function_ulong Function
%3 = OpVariable %_ptr_Function_ulong Function
%4 = OpVariable %_ptr_Function_ulong Function
%5 = OpVariable %_ptr_Function_ulong Function
%6 = OpVariable %_ptr_Function_uint Function
%7 = OpVariable %_ptr_Function_uint Function
%8 = OpVariable %_ptr_Function_uint Function
OpStore %2 %9
OpStore %3 %10
%12 = OpLoad %ulong %2
%11 = OpCopyObject %ulong %12
OpStore %4 %11
%14 = OpLoad %ulong %3
%13 = OpCopyObject %ulong %14
OpStore %5 %13
%16 = OpLoad %ulong %4
%23 = OpConvertUToPtr %_ptr_Generic_uint %16
%15 = OpLoad %uint %23
OpStore %6 %15
%18 = OpLoad %uint %6
%17 = OpSatConvertSToU %uint %18
OpStore %7 %17
%20 = OpLoad %uint %7
%19 = OpBitcast %uint %20
OpStore %8 %19
%21 = OpLoad %ulong %5
%22 = OpLoad %uint %8
%24 = OpConvertUToPtr %_ptr_Generic_uint %21
OpStore %24 %22
OpReturn
OpFunctionEnd

View file

@ -1,42 +1,49 @@
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%1 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %5 "cvta"
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%4 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%float = OpTypeFloat 32
%_ptr_Function_float = OpTypePointer Function %float
%_ptr_CrossWorkgroup_float = OpTypePointer CrossWorkgroup %float
%5 = OpFunction %void None %4
%6 = OpFunctionParameter %ulong
%7 = OpFunctionParameter %ulong
%21 = OpLabel
%8 = OpVariable %_ptr_Function_ulong Function
%9 = OpVariable %_ptr_Function_ulong Function
%10 = OpVariable %_ptr_Function_float Function
OpStore %8 %6
OpStore %9 %7
%12 = OpLoad %ulong %8
%11 = OpCopyObject %ulong %12
OpStore %8 %11
%14 = OpLoad %ulong %9
%13 = OpCopyObject %ulong %14
OpStore %9 %13
%16 = OpLoad %ulong %8
%19 = OpConvertUToPtr %_ptr_CrossWorkgroup_float %16
%15 = OpLoad %float %19
OpStore %10 %15
%17 = OpLoad %ulong %9
%18 = OpLoad %float %10
%20 = OpConvertUToPtr %_ptr_CrossWorkgroup_float %17
OpStore %20 %18
OpReturn
OpFunctionEnd
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%25 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %1 "cvta"
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%28 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%float = OpTypeFloat 32
%_ptr_Function_float = OpTypePointer Function %float
%_ptr_CrossWorkgroup_float = OpTypePointer CrossWorkgroup %float
%1 = OpFunction %void None %28
%7 = OpFunctionParameter %ulong
%8 = OpFunctionParameter %ulong
%23 = OpLabel
%2 = OpVariable %_ptr_Function_ulong Function
%3 = OpVariable %_ptr_Function_ulong Function
%4 = OpVariable %_ptr_Function_ulong Function
%5 = OpVariable %_ptr_Function_ulong Function
%6 = OpVariable %_ptr_Function_float Function
OpStore %2 %7
OpStore %3 %8
%10 = OpLoad %ulong %2
%9 = OpCopyObject %ulong %10
OpStore %4 %9
%12 = OpLoad %ulong %3
%11 = OpCopyObject %ulong %12
OpStore %5 %11
%14 = OpLoad %ulong %4
%13 = OpCopyObject %ulong %14
OpStore %4 %13
%16 = OpLoad %ulong %5
%15 = OpCopyObject %ulong %16
OpStore %5 %15
%18 = OpLoad %ulong %4
%21 = OpConvertUToPtr %_ptr_CrossWorkgroup_float %18
%17 = OpLoad %float %21
OpStore %6 %17
%19 = OpLoad %ulong %5
%20 = OpLoad %float %6
%22 = OpConvertUToPtr %_ptr_CrossWorkgroup_float %19
OpStore %22 %20
OpReturn
OpFunctionEnd

View file

@ -1,38 +1,41 @@
; SPIR-V
; Version: 1.5
; Generator: Khronos SPIR-V Tools Assembler; 0
; Bound: 20
; Schema: 0
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%1 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %2 "ld_st"
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%5 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%_ptr_Generic_ulong = OpTypePointer Generic %ulong
%2 = OpFunction %void None %5
%8 = OpFunctionParameter %ulong
%9 = OpFunctionParameter %ulong
%10 = OpLabel
%11 = OpVariable %_ptr_Function_ulong Function
%12 = OpVariable %_ptr_Function_ulong Function
%13 = OpVariable %_ptr_Function_ulong Function
OpStore %11 %8
OpStore %12 %9
%14 = OpLoad %ulong %11
%15 = OpConvertUToPtr %_ptr_Generic_ulong %14
%16 = OpLoad %ulong %15
OpStore %13 %16
%17 = OpLoad %ulong %12
%18 = OpLoad %ulong %13
%19 = OpConvertUToPtr %_ptr_Generic_ulong %17
OpStore %19 %18
OpReturn
OpFunctionEnd
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%21 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %1 "ld_st"
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%24 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%_ptr_Generic_ulong = OpTypePointer Generic %ulong
%1 = OpFunction %void None %24
%7 = OpFunctionParameter %ulong
%8 = OpFunctionParameter %ulong
%19 = OpLabel
%2 = OpVariable %_ptr_Function_ulong Function
%3 = OpVariable %_ptr_Function_ulong Function
%4 = OpVariable %_ptr_Function_ulong Function
%5 = OpVariable %_ptr_Function_ulong Function
%6 = OpVariable %_ptr_Function_ulong Function
OpStore %2 %7
OpStore %3 %8
%10 = OpLoad %ulong %2
%9 = OpCopyObject %ulong %10
OpStore %4 %9
%12 = OpLoad %ulong %3
%11 = OpCopyObject %ulong %12
OpStore %5 %11
%14 = OpLoad %ulong %4
%17 = OpConvertUToPtr %_ptr_Generic_ulong %14
%13 = OpLoad %ulong %17
OpStore %6 %13
%15 = OpLoad %ulong %5
%16 = OpLoad %ulong %6
%18 = OpConvertUToPtr %_ptr_Generic_ulong %15
OpStore %18 %16
OpReturn
OpFunctionEnd

View file

@ -1,38 +1,46 @@
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%1 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %5 "local_align"
OpDecorate %8 Alignment 8
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%4 = OpTypeFunction %void %ulong %ulong
%uchar = OpTypeInt 8 0
%_arr_uchar_8 = OpTypeArray %uchar %8
%_ptr_Function__arr_uchar_8 = OpTypePointer Function %_arr_uchar_8
%_ptr_Function_ulong = OpTypePointer Function %ulong
%_ptr_Generic_ulong = OpTypePointer Generic %ulong
%5 = OpFunction %void None %4
%6 = OpFunctionParameter %ulong
%7 = OpFunctionParameter %ulong
%18 = OpLabel
%8 = OpVariable %_ptr_Function__arr_uchar_8 Workgroup
%9 = OpVariable %_ptr_Function_ulong Function
%10 = OpVariable %_ptr_Function_ulong Function
%11 = OpVariable %_ptr_Function_ulong Function
OpStore %9 %6
OpStore %10 %7
%13 = OpLoad %ulong %9
%16 = OpConvertUToPtr %_ptr_Generic_ulong %13
%12 = OpLoad %ulong %16
OpStore %11 %12
%14 = OpLoad %ulong %10
%15 = OpLoad %ulong %11
%17 = OpConvertUToPtr %_ptr_Generic_ulong %14
OpStore %17 %15
OpReturn
OpFunctionEnd
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%22 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %1 "local_align"
OpDecorate %4 Alignment 8
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%25 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%uchar = OpTypeInt 8 0
%_arr_uchar_8 = OpTypeArray %uchar %8
%_ptr_Function__arr_uchar_8 = OpTypePointer Function %_arr_uchar_8
%_ptr_Generic_ulong = OpTypePointer Generic %ulong
%1 = OpFunction %void None %25
%8 = OpFunctionParameter %ulong
%9 = OpFunctionParameter %ulong
%20 = OpLabel
%2 = OpVariable %_ptr_Function_ulong Function
%3 = OpVariable %_ptr_Function_ulong Function
%4 = OpVariable %_ptr_Function__arr_uchar_8 Workgroup
%5 = OpVariable %_ptr_Function_ulong Function
%6 = OpVariable %_ptr_Function_ulong Function
%7 = OpVariable %_ptr_Function_ulong Function
OpStore %2 %8
OpStore %3 %9
%11 = OpLoad %ulong %2
%10 = OpCopyObject %ulong %11
OpStore %5 %10
%13 = OpLoad %ulong %3
%12 = OpCopyObject %ulong %13
OpStore %6 %12
%15 = OpLoad %ulong %5
%18 = OpConvertUToPtr %_ptr_Generic_ulong %15
%14 = OpLoad %ulong %18
OpStore %7 %14
%16 = OpLoad %ulong %6
%17 = OpLoad %ulong %7
%19 = OpConvertUToPtr %_ptr_Generic_ulong %16
OpStore %19 %17
OpReturn
OpFunctionEnd

View file

@ -14,7 +14,7 @@ use std::fmt;
use std::fmt::{Debug, Display, Formatter};
use std::mem;
use std::slice;
use std::{collections::HashMap, ptr, str};
use std::{borrow::Cow, collections::HashMap, env, fs, path::PathBuf, ptr, str};
macro_rules! test_ptx {
($fn_name:ident, $input:expr, $output:expr) => {
@ -32,8 +32,9 @@ macro_rules! test_ptx {
#[test]
fn [<$fn_name _spvtxt>]() -> Result<(), Box<dyn std::error::Error>> {
let ptx_txt = include_str!(concat!(stringify!($fn_name), ".ptx"));
let spirv_file_name = concat!(stringify!($fn_name), ".spvtxt");
let spirv_txt = include_bytes!(concat!(stringify!($fn_name), ".spvtxt"));
test_spvtxt_assert(ptx_txt, spirv_txt)
test_spvtxt_assert(ptx_txt, spirv_txt, spirv_file_name)
}
}
};
@ -140,6 +141,7 @@ fn run_spirv<T: From<u8> + ze::SafeRepr + Copy + Debug>(
fn test_spvtxt_assert<'a>(
ptx_txt: &'a str,
spirv_txt: &'a [u8],
spirv_file_name: &'a str,
) -> Result<(), Box<dyn error::Error + 'a>> {
let mut errors = Vec::new();
let ast = ptx::ModuleParser::new().parse(&mut errors, ptx_txt)?;
@ -191,16 +193,27 @@ fn test_spvtxt_assert<'a>(
)
};
unsafe { spirv_tools::spvContextDestroy(spv_context) };
if result == spv_result_t::SPV_SUCCESS {
let spirv_text = if result == spv_result_t::SPV_SUCCESS {
let raw_text = unsafe {
std::slice::from_raw_parts((*spv_text).str_ as *const u8, (*spv_text).length)
};
let spv_from_ptx_text = unsafe { str::from_utf8_unchecked(raw_text) };
// TODO: stop leaking kernel text
panic!(spv_from_ptx_text);
Cow::Borrowed(spv_from_ptx_text)
} else {
panic!(ptx_mod.disassemble());
Cow::Owned(ptx_mod.disassemble())
};
if let Ok(dump_path) = env::var("NOTCUDA_TEST_SPIRV_DUMP_DIR") {
let mut path = PathBuf::from(dump_path);
if let Ok(()) = fs::create_dir_all(&path) {
path.push(spirv_file_name);
#[allow(unused_must_use)]
{
fs::write(path, spirv_text.as_bytes());
}
}
}
panic!(spirv_text);
}
unsafe { spirv_tools::spvContextDestroy(spv_context) };
Ok(())

View file

@ -1,43 +1,45 @@
; SPIR-V
; Version: 1.5
; Generator: Khronos SPIR-V Tools Assembler; 0
; Bound: 23
; Schema: 0
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%1 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %2 "mov"
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%5 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%_ptr_Generic_ulong = OpTypePointer Generic %ulong
%2 = OpFunction %void None %5
%8 = OpFunctionParameter %ulong
%9 = OpFunctionParameter %ulong
%10 = OpLabel
%11 = OpVariable %_ptr_Function_ulong Function
%12 = OpVariable %_ptr_Function_ulong Function
%13 = OpVariable %_ptr_Function_ulong Function
%14 = OpVariable %_ptr_Function_ulong Function
OpStore %11 %8
OpStore %12 %9
%15 = OpLoad %ulong %11
%16 = OpConvertUToPtr %_ptr_Generic_ulong %15
%17 = OpLoad %ulong %16
OpStore %13 %17
%18 = OpLoad %ulong %13
%19 = OpCopyObject %ulong %18
OpStore %14 %19
%20 = OpLoad %ulong %12
%21 = OpLoad %ulong %14
%22 = OpConvertUToPtr %_ptr_Generic_ulong %20
OpStore %22 %21
OpReturn
OpFunctionEnd
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%24 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %1 "mov"
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%27 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%_ptr_Generic_ulong = OpTypePointer Generic %ulong
%1 = OpFunction %void None %27
%8 = OpFunctionParameter %ulong
%9 = OpFunctionParameter %ulong
%22 = OpLabel
%2 = OpVariable %_ptr_Function_ulong Function
%3 = OpVariable %_ptr_Function_ulong Function
%4 = OpVariable %_ptr_Function_ulong Function
%5 = OpVariable %_ptr_Function_ulong Function
%6 = OpVariable %_ptr_Function_ulong Function
%7 = OpVariable %_ptr_Function_ulong Function
OpStore %2 %8
OpStore %3 %9
%11 = OpLoad %ulong %2
%10 = OpCopyObject %ulong %11
OpStore %4 %10
%13 = OpLoad %ulong %3
%12 = OpCopyObject %ulong %13
OpStore %5 %12
%15 = OpLoad %ulong %4
%20 = OpConvertUToPtr %_ptr_Generic_ulong %15
%14 = OpLoad %ulong %20
OpStore %6 %14
%17 = OpLoad %ulong %6
%16 = OpCopyObject %ulong %17
OpStore %7 %16
%18 = OpLoad %ulong %5
%19 = OpLoad %ulong %7
%21 = OpConvertUToPtr %_ptr_Generic_ulong %18
OpStore %21 %19
OpReturn
OpFunctionEnd

View file

@ -1,43 +1,46 @@
; SPIR-V
; Version: 1.5
; Generator: Khronos SPIR-V Tools Assembler; 0
; Bound: 24
; Schema: 0
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%1 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %2 "mul_hi"
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%5 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%_ptr_Generic_ulong = OpTypePointer Generic %ulong
%ulong_2 = OpConstant %ulong 2
%2 = OpFunction %void None %5
%9 = OpFunctionParameter %ulong
%10 = OpFunctionParameter %ulong
%11 = OpLabel
%12 = OpVariable %_ptr_Function_ulong Function
%13 = OpVariable %_ptr_Function_ulong Function
%14 = OpVariable %_ptr_Function_ulong Function
%15 = OpVariable %_ptr_Function_ulong Function
OpStore %12 %9
OpStore %13 %10
%16 = OpLoad %ulong %12
%17 = OpConvertUToPtr %_ptr_Generic_ulong %16
%18 = OpLoad %ulong %17
OpStore %14 %18
%19 = OpLoad %ulong %14
%20 = OpExtInst %ulong %1 u_mul_hi %19 %ulong_2
OpStore %15 %20
%21 = OpLoad %ulong %13
%22 = OpLoad %ulong %15
%23 = OpConvertUToPtr %_ptr_Generic_ulong %21
OpStore %23 %22
OpReturn
OpFunctionEnd
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%25 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %1 "mul_hi"
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%28 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%_ptr_Generic_ulong = OpTypePointer Generic %ulong
%ulong_2 = OpConstant %ulong 2
%1 = OpFunction %void None %28
%8 = OpFunctionParameter %ulong
%9 = OpFunctionParameter %ulong
%23 = OpLabel
%2 = OpVariable %_ptr_Function_ulong Function
%3 = OpVariable %_ptr_Function_ulong Function
%4 = OpVariable %_ptr_Function_ulong Function
%5 = OpVariable %_ptr_Function_ulong Function
%6 = OpVariable %_ptr_Function_ulong Function
%7 = OpVariable %_ptr_Function_ulong Function
OpStore %2 %8
OpStore %3 %9
%11 = OpLoad %ulong %2
%10 = OpCopyObject %ulong %11
OpStore %4 %10
%13 = OpLoad %ulong %3
%12 = OpCopyObject %ulong %13
OpStore %5 %12
%15 = OpLoad %ulong %4
%21 = OpConvertUToPtr %_ptr_Generic_ulong %15
%14 = OpLoad %ulong %21
OpStore %6 %14
%17 = OpLoad %ulong %6
%16 = OpExtInst %ulong %25 u_mul_hi %17 %ulong_2
OpStore %7 %16
%18 = OpLoad %ulong %5
%19 = OpLoad %ulong %7
%22 = OpConvertUToPtr %_ptr_Generic_ulong %18
OpStore %22 %19
OpReturn
OpFunctionEnd

View file

@ -1,38 +1,46 @@
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%1 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %5 "mul_lo"
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%4 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%_ptr_Generic_ulong = OpTypePointer Generic %ulong
%ulong_2 = OpConstant %ulong 2
%5 = OpFunction %void None %4
%6 = OpFunctionParameter %ulong
%7 = OpFunctionParameter %ulong
%21 = OpLabel
%8 = OpVariable %_ptr_Function_ulong Function
%9 = OpVariable %_ptr_Function_ulong Function
%10 = OpVariable %_ptr_Function_ulong Function
%11 = OpVariable %_ptr_Function_ulong Function
OpStore %8 %6
OpStore %9 %7
%12 = OpLoad %ulong %8
%19 = OpConvertUToPtr %_ptr_Generic_ulong %12
%13 = OpLoad %ulong %19
OpStore %10 %13
%14 = OpLoad %ulong %10
%15 = OpIMul %ulong %14 %ulong_2
OpStore %11 %15
%16 = OpLoad %ulong %9
%17 = OpLoad %ulong %11
%20 = OpConvertUToPtr %_ptr_Generic_ulong %16
OpStore %20 %17
OpReturn
OpFunctionEnd
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%25 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %1 "mul_lo"
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%28 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%_ptr_Generic_ulong = OpTypePointer Generic %ulong
%ulong_2 = OpConstant %ulong 2
%1 = OpFunction %void None %28
%8 = OpFunctionParameter %ulong
%9 = OpFunctionParameter %ulong
%23 = OpLabel
%2 = OpVariable %_ptr_Function_ulong Function
%3 = OpVariable %_ptr_Function_ulong Function
%4 = OpVariable %_ptr_Function_ulong Function
%5 = OpVariable %_ptr_Function_ulong Function
%6 = OpVariable %_ptr_Function_ulong Function
%7 = OpVariable %_ptr_Function_ulong Function
OpStore %2 %8
OpStore %3 %9
%11 = OpLoad %ulong %2
%10 = OpCopyObject %ulong %11
OpStore %4 %10
%13 = OpLoad %ulong %3
%12 = OpCopyObject %ulong %13
OpStore %5 %12
%15 = OpLoad %ulong %4
%21 = OpConvertUToPtr %_ptr_Generic_ulong %15
%14 = OpLoad %ulong %21
OpStore %6 %14
%17 = OpLoad %ulong %6
%16 = OpIMul %ulong %17 %ulong_2
OpStore %7 %16
%18 = OpLoad %ulong %5
%19 = OpLoad %ulong %7
%22 = OpConvertUToPtr %_ptr_Generic_ulong %18
OpStore %22 %19
OpReturn
OpFunctionEnd

View file

@ -1,37 +1,45 @@
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%1 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %5 "not"
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%4 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%_ptr_Generic_ulong = OpTypePointer Generic %ulong
%5 = OpFunction %void None %4
%6 = OpFunctionParameter %ulong
%7 = OpFunctionParameter %ulong
%20 = OpLabel
%8 = OpVariable %_ptr_Function_ulong Function
%9 = OpVariable %_ptr_Function_ulong Function
%10 = OpVariable %_ptr_Function_ulong Function
%11 = OpVariable %_ptr_Function_ulong Function
OpStore %8 %6
OpStore %9 %7
%13 = OpLoad %ulong %8
%18 = OpConvertUToPtr %_ptr_Generic_ulong %13
%12 = OpLoad %ulong %18
OpStore %10 %12
%15 = OpLoad %ulong %10
%14 = OpNot %ulong %15
OpStore %11 %14
%16 = OpLoad %ulong %9
%17 = OpLoad %ulong %11
%19 = OpConvertUToPtr %_ptr_Generic_ulong %16
OpStore %19 %17
OpReturn
OpFunctionEnd
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%24 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %1 "not"
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%27 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%_ptr_Generic_ulong = OpTypePointer Generic %ulong
%1 = OpFunction %void None %27
%8 = OpFunctionParameter %ulong
%9 = OpFunctionParameter %ulong
%22 = OpLabel
%2 = OpVariable %_ptr_Function_ulong Function
%3 = OpVariable %_ptr_Function_ulong Function
%4 = OpVariable %_ptr_Function_ulong Function
%5 = OpVariable %_ptr_Function_ulong Function
%6 = OpVariable %_ptr_Function_ulong Function
%7 = OpVariable %_ptr_Function_ulong Function
OpStore %2 %8
OpStore %3 %9
%11 = OpLoad %ulong %2
%10 = OpCopyObject %ulong %11
OpStore %4 %10
%13 = OpLoad %ulong %3
%12 = OpCopyObject %ulong %13
OpStore %5 %12
%15 = OpLoad %ulong %4
%20 = OpConvertUToPtr %_ptr_Generic_ulong %15
%14 = OpLoad %ulong %20
OpStore %6 %14
%17 = OpLoad %ulong %6
%16 = OpNot %ulong %17
OpStore %7 %16
%18 = OpLoad %ulong %5
%19 = OpLoad %ulong %7
%21 = OpConvertUToPtr %_ptr_Generic_ulong %18
OpStore %21 %19
OpReturn
OpFunctionEnd

View file

@ -1,65 +1,73 @@
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%1 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %5 "setp"
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%4 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%bool = OpTypeBool
%_ptr_Function_bool = OpTypePointer Function %bool
%_ptr_Generic_ulong = OpTypePointer Generic %ulong
%ulong_8 = OpConstant %ulong 8
%ulong_1 = OpConstant %ulong 1
%ulong_2 = OpConstant %ulong 2
%5 = OpFunction %void None %4
%6 = OpFunctionParameter %ulong
%7 = OpFunctionParameter %ulong
%39 = OpLabel
%8 = OpVariable %_ptr_Function_ulong Function
%9 = OpVariable %_ptr_Function_ulong Function
%10 = OpVariable %_ptr_Function_ulong Function
%11 = OpVariable %_ptr_Function_ulong Function
%12 = OpVariable %_ptr_Function_ulong Function
%13 = OpVariable %_ptr_Function_bool Function
OpStore %8 %6
OpStore %9 %7
%19 = OpLoad %ulong %8
%35 = OpConvertUToPtr %_ptr_Generic_ulong %19
%18 = OpLoad %ulong %35
OpStore %10 %18
%21 = OpLoad %ulong %8
%36 = OpCopyObject %ulong %21
%32 = OpIAdd %ulong %36 %ulong_8
%37 = OpConvertUToPtr %_ptr_Generic_ulong %32
%20 = OpLoad %ulong %37
OpStore %11 %20
%23 = OpLoad %ulong %10
%24 = OpLoad %ulong %11
%22 = OpULessThan %bool %23 %24
OpStore %13 %22
%25 = OpLoad %bool %13
OpBranchConditional %25 %14 %15
%14 = OpLabel
%26 = OpCopyObject %ulong %ulong_1
OpStore %12 %26
OpBranch %15
%15 = OpLabel
%27 = OpLoad %bool %13
OpBranchConditional %27 %17 %16
%16 = OpLabel
%28 = OpCopyObject %ulong %ulong_2
OpStore %12 %28
OpBranch %17
%17 = OpLabel
%29 = OpLoad %ulong %9
%30 = OpLoad %ulong %12
%38 = OpConvertUToPtr %_ptr_Generic_ulong %29
OpStore %38 %30
OpReturn
OpFunctionEnd
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%43 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %1 "setp"
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%46 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%bool = OpTypeBool
%_ptr_Function_bool = OpTypePointer Function %bool
%_ptr_Generic_ulong = OpTypePointer Generic %ulong
%ulong_8 = OpConstant %ulong 8
%ulong_1 = OpConstant %ulong 1
%ulong_2 = OpConstant %ulong 2
%1 = OpFunction %void None %46
%14 = OpFunctionParameter %ulong
%15 = OpFunctionParameter %ulong
%41 = OpLabel
%2 = OpVariable %_ptr_Function_ulong Function
%3 = OpVariable %_ptr_Function_ulong Function
%4 = OpVariable %_ptr_Function_ulong Function
%5 = OpVariable %_ptr_Function_ulong Function
%6 = OpVariable %_ptr_Function_ulong Function
%7 = OpVariable %_ptr_Function_ulong Function
%8 = OpVariable %_ptr_Function_ulong Function
%9 = OpVariable %_ptr_Function_bool Function
OpStore %2 %14
OpStore %3 %15
%17 = OpLoad %ulong %2
%16 = OpCopyObject %ulong %17
OpStore %4 %16
%19 = OpLoad %ulong %3
%18 = OpCopyObject %ulong %19
OpStore %5 %18
%21 = OpLoad %ulong %4
%37 = OpConvertUToPtr %_ptr_Generic_ulong %21
%20 = OpLoad %ulong %37
OpStore %6 %20
%23 = OpLoad %ulong %4
%38 = OpCopyObject %ulong %23
%34 = OpIAdd %ulong %38 %ulong_8
%39 = OpConvertUToPtr %_ptr_Generic_ulong %34
%22 = OpLoad %ulong %39
OpStore %7 %22
%25 = OpLoad %ulong %6
%26 = OpLoad %ulong %7
%24 = OpULessThan %bool %25 %26
OpStore %9 %24
%27 = OpLoad %bool %9
OpBranchConditional %27 %10 %11
%10 = OpLabel
%28 = OpCopyObject %ulong %ulong_1
OpStore %8 %28
OpBranch %11
%11 = OpLabel
%29 = OpLoad %bool %9
OpBranchConditional %29 %13 %12
%12 = OpLabel
%30 = OpCopyObject %ulong %ulong_2
OpStore %8 %30
OpBranch %13
%13 = OpLabel
%31 = OpLoad %ulong %5
%32 = OpLoad %ulong %8
%40 = OpConvertUToPtr %_ptr_Generic_ulong %31
OpStore %40 %32
OpReturn
OpFunctionEnd

View file

@ -1,39 +1,47 @@
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%1 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %5 "shl"
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%4 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%_ptr_Generic_ulong = OpTypePointer Generic %ulong
%uint = OpTypeInt 32 0
%uint_2 = OpConstant %uint 2
%5 = OpFunction %void None %4
%6 = OpFunctionParameter %ulong
%7 = OpFunctionParameter %ulong
%21 = OpLabel
%8 = OpVariable %_ptr_Function_ulong Function
%9 = OpVariable %_ptr_Function_ulong Function
%10 = OpVariable %_ptr_Function_ulong Function
%11 = OpVariable %_ptr_Function_ulong Function
OpStore %8 %6
OpStore %9 %7
%13 = OpLoad %ulong %8
%19 = OpConvertUToPtr %_ptr_Generic_ulong %13
%12 = OpLoad %ulong %19
OpStore %10 %12
%15 = OpLoad %ulong %10
%14 = OpShiftLeftLogical %ulong %15 %uint_2
OpStore %11 %14
%16 = OpLoad %ulong %9
%17 = OpLoad %ulong %11
%20 = OpConvertUToPtr %_ptr_Generic_ulong %16
OpStore %20 %17
OpReturn
OpFunctionEnd
OpCapability GenericPointer
OpCapability Linkage
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpCapability Int8
%25 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %1 "shl"
%void = OpTypeVoid
%ulong = OpTypeInt 64 0
%28 = OpTypeFunction %void %ulong %ulong
%_ptr_Function_ulong = OpTypePointer Function %ulong
%_ptr_Generic_ulong = OpTypePointer Generic %ulong
%uint = OpTypeInt 32 0
%uint_2 = OpConstant %uint 2
%1 = OpFunction %void None %28
%8 = OpFunctionParameter %ulong
%9 = OpFunctionParameter %ulong
%23 = OpLabel
%2 = OpVariable %_ptr_Function_ulong Function
%3 = OpVariable %_ptr_Function_ulong Function
%4 = OpVariable %_ptr_Function_ulong Function
%5 = OpVariable %_ptr_Function_ulong Function
%6 = OpVariable %_ptr_Function_ulong Function
%7 = OpVariable %_ptr_Function_ulong Function
OpStore %2 %8
OpStore %3 %9
%11 = OpLoad %ulong %2
%10 = OpCopyObject %ulong %11
OpStore %4 %10
%13 = OpLoad %ulong %3
%12 = OpCopyObject %ulong %13
OpStore %5 %12
%15 = OpLoad %ulong %4
%21 = OpConvertUToPtr %_ptr_Generic_ulong %15
%14 = OpLoad %ulong %21
OpStore %6 %14
%17 = OpLoad %ulong %6
%16 = OpShiftLeftLogical %ulong %17 %uint_2
OpStore %7 %16
%18 = OpLoad %ulong %5
%19 = OpLoad %ulong %7
%22 = OpConvertUToPtr %_ptr_Generic_ulong %18
OpStore %22 %19
OpReturn
OpFunctionEnd

File diff suppressed because it is too large Load diff