methods containing assembly code not inlined by 'inline' keyword
Original Reporter info from Mantis: NickleSi
-
Reporter name: Si Nicholson
Original Reporter info from Mantis: NickleSi
- Reporter name: Si Nicholson
Description:
Was hoping to create a more user friendly method of accessing advanced X86 / ARM SIMD functions...
B16x4 = array [0..3] of Word;
MM0_16 = object
end;
MM1_16 = object
end;
operator := (var words: B16x4) : MM0_16; inline;
operator := (var words: B16x4) : MM1_16; inline;
operator := (var words: MM0_16) : B16x4; inline;
operator := (var words: MM1_16 : B16x4; inline;
operator * (mmx: MM1_16) : MM0_16;
operator * (mmx: MM0_16) : MM1_16;
implementation
operator := (var words: B16x4) : MM0_16;
begin asm movq mm0, [words] end; end;
operator := (var words: B16x4) : MM1_16;
begin asm movq mm1, [words] end; end;
operator := (var words: MM0_16) : B16x4;
begin asm [words], words end; end;
operator := (var words: MM1_16) : B16x4;
begin asm [words], words end; end;
operator * (words: MM0_16) : MM1_16;
begin asm pmullw mm0, mm1 end; end;
operator * (words: MM1_16) : MM0_16;
begin asm pmullw mm0, mm1 end; end;
.....
var x : MM0_16 = [1,2,3,4];
y : MM1_16 = [5,6,7,8];
x:=x*y; // pmulLQ mm0, mm1
I've included an example with operator overloading and memory variables (rather than assignment from/to RAX as that would be handled by an RAX type in the same vein), but x.mul (y) or x.mulLQ (y) will not inline either. Intrinsics are OK but inlined assembly methods would improve overall readability and ease of use in some cases. Personally I like assembly, but manually rolling out and inserting it inline makes for messy code. This is my example, but there are less generic reasons to implement inlined asm methods. The idea of assigning a variable to mmx and sse registers is 'prettier'.
Mantis conversion info:
- Mantis ID: 38547