SPIRV-Cross/reference/shaders-msl-no-opt/asm/comp/opptrdiff-opptraccesschain-elem-offset.spv14.asm.comp
Bill Hollings 5493b3030e MSL: Support OpPtrEqual, OpPtrNotEqual, and OpPtrDiff.
- Add CompilerMSL::emit_binary_ptr_op() and to_ptr_expression()
  to emit binary pointer op. Compare matrix addresses without automatic
  transpose() conversion, to avoid error taking address of temporary copy.
- Add Compiler::add_active_interface_variable() to also track active
  interface vars in the entry point for SPIR-V 1.4 and above.
- For OpPtrAccessChain that ends in array element, use Element
  as offset to existing index, otherwise it will access into
  array dimension that doesn't exist.
- Dereference pointer function call arguments. Ultimately, this
  dereferencing is actually backwards, and in future, we should aim
  to properly support passing pointer variables between functions,
  but such a refactoring was beyond the scope here.
- Use [] to declare array of pointers, as array<T*> is not supported in MSL.
- Add unit test shaders.
2022-09-14 15:19:15 -04:00

46 lines
782 B
Plaintext

#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct _7
{
int _m0;
int _m1[1];
};
struct _9
{
int2 _m0[1];
};
kernel void main0(device _7& _2 [[buffer(0)]], device _9& _3 [[buffer(1)]])
{
int _28 = _2._m0;
device int* _4 = &_2._m1[0];
device int* _5 = &_2._m1[0 + _28];
int _34;
if (!(_28 <= 0))
{
_34 = 0;
for (;;)
{
device int* _36 = _4;
device int* _37 = _5;
int _35 = _34 + 1;
_4 = &_36[1];
_5 = &_37[-1];
_3._m0[_34] = int2(_36 - _37, _37 - _36);
if (_34 >= _28)
{
break;
}
else
{
_34 = _35;
}
}
}
}