(ops)
| 112 | CXXTypeToIR[op_val] = IRType(op_key, op_val) |
| 113 | |
| 114 | def parse_ops(ops): |
| 115 | for op_class, opslist in ops.items(): |
| 116 | for op, op_val in opslist.items(): |
| 117 | if "Ignore" in op_val: |
| 118 | # Skip these |
| 119 | continue |
| 120 | |
| 121 | OpDef = OpDefinition() |
| 122 | |
| 123 | # Check if we have a destination |
| 124 | # Only happens if the IR name contains `=` |
| 125 | EqualSplit = op.split("=", 1) |
| 126 | |
| 127 | RHS = EqualSplit[0].strip() |
| 128 | if len(EqualSplit) > 1: |
| 129 | LHS = EqualSplit[0].strip() |
| 130 | RHS = EqualSplit[1].strip() |
| 131 | |
| 132 | if ":" in LHS: |
| 133 | # Named destinations. This is a hack, but so is the entire |
| 134 | # multi-destination support bolten onto the old IR... |
| 135 | # |
| 136 | # Named destinations require side effects because they break |
| 137 | # SSA hard. Validate that. |
| 138 | assert("HasSideEffects" in op_val and op_val["HasSideEffects"]) |
| 139 | |
| 140 | for Dest in LHS.split(","): |
| 141 | Dest = Dest.strip() |
| 142 | DType, Name = Dest.split(":$") |
| 143 | |
| 144 | # If the destination appears also as a source, it is |
| 145 | # read-modify-write. |
| 146 | if Dest in RHS: |
| 147 | # Turn RMW into an in/out source |
| 148 | RHS = RHS.replace(Dest.strip(), f"{DType}:$Inout{Name}") |
| 149 | else: |
| 150 | # Turn named destinations into an out source. |
| 151 | RHS += f", {DType}:$Out{Name}" |
| 152 | else: |
| 153 | # Single anonymous destination |
| 154 | if LHS not in ["SSA", "GPR", "GPRPair", "FPR"]: |
| 155 | ExitError(f"Unknown destination class type {LHS}. Needs to be one of SSA, GPR, GPRPair, FPR") |
| 156 | |
| 157 | OpDef.HasDest = True |
| 158 | OpDef.DestType = LHS |
| 159 | |
| 160 | # IR Op needs to start with a name |
| 161 | RHS = RHS.split(" ", 1) |
| 162 | |
| 163 | if len(RHS) < 1: |
| 164 | ExitError("Missing IR op name. Needs to be a string") |
| 165 | |
| 166 | # Set the op name |
| 167 | OpDef.Name = RHS[0] |
| 168 | |
| 169 | # Parse the arguments |
| 170 | if len(RHS) > 1: |
| 171 | Arguments = RHS[1].strip().split(",") |
no test coverage detected