Krzysztof Parzyszek via llvm-dev
2016-Mar-30 21:50 UTC
[llvm-dev] infer correct types from the pattern
On 3/30/2016 4:42 PM, Rail Shafigulin via llvm-dev wrote:> i'm getting a > > Could not infer all types in pattern! > > error in my backend. it is happening on the following instruction: > > VGETITEM: (set GPR:{i32:f32}:$rD, (extractelt:{i32:f32} > VR:{v4i32:v4f32}:$rA, GPR:i32:$rB)). > > how do i make it use appropriate types? in other words if it is f32 then > use v4v32 and if it is i32 then use v4f32. i'm not sure even where to start?You can use a cast, and force one type in the pattern, then use the other one in a Pat: def VGETITEM: [(set GPR:$rD, (extractelt (v4i32 VR:$rA), GPR:$rB))] def: Pat<(extractelt (v4f32 VR:$rA), GPR:$rB)), (VGETITEM VR:$rA, GPR:$rB)>; -Krzysztof -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Krzysztof Parzyszek via llvm-dev
2016-Apr-05 12:48 UTC
[llvm-dev] infer correct types from the pattern
On 4/4/2016 5:58 PM, Rail Shafigulin wrote:> > What about load instruction? I tried the same approach but I got an error. > > error: In anonymous_570: Type inference contradiction found, merging > '{v4i32:v4f32}' into '{i32:f32}' >Try changing this Pat:> // Cast load of a floating point vector to use the same > // operation as a load of an integer vector. > def: Pat<(set (v4f32 VR:$rD), (load ADDRri:$src)), > (VLWZ VR:$rD, ADDRri:$src)>;to def: Pat<(v4f32 (load ADDRri:$src)), (VLWZ ADDRri:$src)>; That is, remove the "set" from the input pattern and the output operand from the output pattern. Generally, Pats only contain input operands. If you have an error message like the one above, one easy way to locate the problem is to look at the list of all records generated by table-gen: $ llvm-tblgen -print-records -I /path/to/llvm/lib/Target/<target> -I /path/to/llvm/lib/Target -I /path/to/llvm/include /path/to/lib/Target/<target>/<target>.td -o output_file (This is the same invocation of table-gen as for any other purpose, except for the "-print-records" option instead of the typical -gen-... options.) The output_file will then contain all the records that came out of the .td files, for example: def anonymous_1405 { // Pattern Pat T_CMP_pat dag PatternToMatch = (i1 (seteq (i32 IntRegs:$src1), s10ImmPred:$src2)); list<dag> ResultInstrs = [(C2_cmpeqi IntRegs:$src1, s10ImmPred:$src2)]; list<Predicate> Predicates = []; int AddedComplexity = 0; string NAME = ?; } You can look for "anonymous_570" in your case and see where it came from. The comment after "def anonymous..." is a list of classes from which this definition was inherited. -Krzysztof -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation