AST/SIL: Refactor and simplify AST.Type, AST.CanonicalType and SIL.Type

* let `SIL.Type` conform to `TypeProperties` to share the implementation of common type properties between the AST types and `SIL.Type`
* call references to an `AST.Type` `rawType` (instead of just `type`)
* remove unneeded stuff
* add comments
This commit is contained in:
Erik Eckstein
2025-03-14 09:33:24 +01:00
parent 76a1742aca
commit d52f7d1619
17 changed files with 297 additions and 334 deletions

View File

@@ -148,7 +148,7 @@ private func removeMetatypArguments(in specializedFunction: Function, _ context:
if funcArg.type.isRemovableMetatype(in: specializedFunction) {
// Rematerialize the metatype value in the entry block.
let builder = Builder(atBeginOf: entryBlock, context)
let instanceType = funcArg.type.astType.instanceTypeOfMetatype
let instanceType = funcArg.type.canonicalType.instanceTypeOfMetatype
let metatype = builder.createMetatype(ofInstanceType: instanceType, representation: .thick)
funcArg.uses.replaceAll(with: metatype, context)
entryBlock.eraseArgument(at: funcArgIdx, context)
@@ -232,7 +232,7 @@ private func replace(apply: FullApplySite, to specializedCallee: Function, _ con
private extension Type {
func isRemovableMetatype(in function: Function) -> Bool {
if isMetatype {
if astType.representationOfMetatype == .thick {
if representationOfMetatype == .thick {
let instanceTy = loweredInstanceTypeOfMetatype(in: function)
// For structs and enums we know the metatype statically.
return instanceTy.isStruct || instanceTy.isEnum