// #target: macos-x64
module test;
import std;
struct Word {int x;}
typedef Byte = inline ushort;

macro Word Word.add0(self, int other) @operator(+) => { self.x + (int)other };
macro Word Word.add2(self, long other) @operator(+) => { self.x + (int)other };
macro Word Word.add1(self, Byte other) @operator(+) => { self.x + (int)other * 200 };

fn int main()
{
	Word a = {1};
	Byte b = 2;
	Word c = a + b;
	return 0;
}

/* #expect: test.ll

define i32 @main() #0 {
entry:
  %a = alloca %Word, align 4
  %b = alloca i16, align 2
  %c = alloca %Word, align 4
  %self = alloca %Word, align 4
  %other = alloca i16, align 2
  %literal = alloca %Word, align 4
  call void @llvm.memcpy.p0.p0.i32(ptr align 4 %a, ptr align 4 @.__const, i32 4, i1 false)
  store i16 2, ptr %b, align 2
  call void @llvm.memcpy.p0.p0.i32(ptr align 4 %self, ptr align 4 %a, i32 4, i1 false)
  %0 = load i16, ptr %b, align 2
  store i16 %0, ptr %other, align 2
  %1 = load i32, ptr %self, align 4
  %2 = load i16, ptr %other, align 2
  %zext = zext i16 %2 to i32
  %mul = mul i32 %zext, 200
  %add = add i32 %1, %mul
  store i32 %add, ptr %literal, align 4
  call void @llvm.memcpy.p0.p0.i32(ptr align 4 %c, ptr align 4 %literal, i32 4, i1 false)
  ret i32 0
}
