The main problem is that you got the order of arguments to MATCH wrong: it should be the matched pattern first, and then the text to match. Also you need to precede "HL" token with "=", otherwise it is treated as parameter name (at the same time you do not need to put "=" before the parentheses, though it does not hurt there):
macro LD? first , second
match =HL?,first
db $21
dw second
else match ( =HL? ) =, =A?, first,second
db $77
else match ( =HL? ), first
db $36
db second
else match ( expr ),first
if expr relativeto IX?
db $DD,$36
db first-IX?,second
end if
end match
end macro
element IX?
; example instructions to compile
LD HL, $1200 + $34 ; $21,$34,$12
LD (HL) , $11 + 1 ; $36,$12
LD ( HL ) , A ; $77
LD (IX+5-2),1 ; $DD,$36,3,1
Also note that this macro silently ignores any unrecognized syntax, you'd need to add the "else" clauses with some error signaling to make sure that it does not allow any syntax errors to pass undetected.