mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-22 00:26:38 +00:00
Pursuant to recent decisions on #6124, switch `Destroy` to use a `CustomWitness` for its implementation. Right now this is manufacturing no-op implementation functions on each lookup, which obviously isn't ideal but is intended as a first pass. I'm mostly trying to find the right balance between updating the approach to reflect new decisions, while still breaking apart work in a way. The `CoreInterface` logic is intended to build on `CoreIdentifier` support. We have a number of additional interfaces that require specialized logic, and that'll extend pretty far with C++ interop, so it seemed easiest to have a generic function for it. That's what's replacing the logic inside C++ interop that was doing string comparisons (which could have already been moved to `CoreIdentifier`, I just missed it in my first pass). This adds `CustomWitness` support because the `Destroy` witnesses can be imported cross-file. `CustomWitness` was previously only used for C++ types, which don't yet support import, which is why that wasn't previously an issue. The addition of `query_specific_interface_id` is similarly needed in order to get correct sorting of witness blocks when imported. This PR also removes builtin constraint logic (note this is in a separate commit to help review; it's not a separate PR because it's difficult to split apart without tests breaking). This had been made generic with the expectation that destroy, copy, move, and conversions would all need related support. Under the new decision, we are not going to do blanket impls and will instead just manufacture a `CustomWitness` for everything. A lot of SemIR fingerprints change, but that's probably because the addition of `Destroy` on core classes is yielding structural changes.
135 lines
5.1 KiB
C++
135 lines
5.1 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
// This is an X-macro header. It does not use `#include` guards, and instead is
|
|
// designed to be `#include`ed after the x-macro is defined in order for its
|
|
// inclusion to expand to the desired output. Macro definitions are cleaned up
|
|
// at the end of this file.
|
|
//
|
|
// Supported x-macro is:
|
|
// - CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(Name)
|
|
// Defines a builtin function type.
|
|
|
|
#if !defined(CARBON_SEM_IR_BUILTIN_FUNCTION_KIND)
|
|
#error \
|
|
"Must define CARBON_SEM_IR_BUILTIN_FUNCTION_KIND x-macro to use this file."
|
|
#define CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(Name)
|
|
#endif
|
|
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(None)
|
|
|
|
// A no-op function definition; calls should be elided when lowering.
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(NoOp)
|
|
|
|
// A primitive copy for types whose value and initializing representation are
|
|
// the same.
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(PrimitiveCopy)
|
|
|
|
// Temporary builtins for primitive IO.
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(PrintChar)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(PrintInt)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(ReadChar)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(StringAt)
|
|
|
|
// Type factories.
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(CharLiteralMakeType)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntLiteralMakeType)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(FloatLiteralMakeType)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntMakeTypeSigned)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntMakeTypeUnsigned)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(FloatMakeType)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(BoolMakeType)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(MaybeUnformedMakeType)
|
|
|
|
// Character conversion.
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(CharConvertChecked)
|
|
|
|
// Integer conversion.
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntConvert)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntConvertChecked)
|
|
|
|
// Integer arithmetic.
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntSNegate)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntSAdd)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntSSub)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntSMul)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntSDiv)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntSMod)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntUNegate)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntUAdd)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntUSub)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntUMul)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntUDiv)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntUMod)
|
|
|
|
// Integer bitwise.
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntComplement)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntAnd)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntOr)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntXor)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntLeftShift)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntRightShift)
|
|
|
|
// Integer comparison.
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntEq)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntNeq)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntLess)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntLessEq)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntGreater)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntGreaterEq)
|
|
|
|
// Integer compound assignment.
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntSAddAssign)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntSSubAssign)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntSMulAssign)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntSDivAssign)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntSModAssign)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntUAddAssign)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntUSubAssign)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntUMulAssign)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntUDivAssign)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntUModAssign)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntAndAssign)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntOrAssign)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntXorAssign)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntLeftShiftAssign)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntRightShiftAssign)
|
|
|
|
// Float arithmetic.
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(FloatNegate)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(FloatAdd)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(FloatSub)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(FloatMul)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(FloatDiv)
|
|
|
|
// Float compound assignment.
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(FloatAddAssign)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(FloatSubAssign)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(FloatMulAssign)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(FloatDivAssign)
|
|
|
|
// Float conversion.
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(FloatConvertChecked)
|
|
|
|
// Float comparison.
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(FloatEq)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(FloatNeq)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(FloatLess)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(FloatLessEq)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(FloatGreater)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(FloatGreaterEq)
|
|
|
|
// Bool comparison.
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(BoolEq)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(BoolNeq)
|
|
|
|
// Pointers.
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(PointerMakeNull)
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(PointerIsNull)
|
|
|
|
// Facet type combination.
|
|
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(TypeAnd)
|
|
|
|
#undef CARBON_SEM_IR_BUILTIN_FUNCTION_KIND
|