-
Add traits for Reactor arguments and return types · 351be42eBen Clayton authored
Provides a number of template trait types for Reactor primitive types: CToReactorT<T> transforms the C-type (T) into a suitable Reactor equivalent. Pointer types are now generalized, allowing for translations of T** types. IsRValue<T>::value and IsLValue<T>::value are true iff T is of the respective Reactor type. ReactorType<T> resolves to the corresponding LValue Reactor type for T, where T can be a C-type, RValue or LValue. ValueOf<T> returns a rr::Value* for a C-value, RValue or LValue. This is now used by a single definition of Return(), fixing bad type coercion which in turn produced illegal LLVM IR. CanBeUsedAsReturn<T>::value is true iff T can be used as a function return type. CanBeUsedAsParameter<T>::value is true iff T can be used as a function parameter type. Function signatures are now statically checked that all parameter types and the return type are valid, providing a human readable error message if an invalid type is used (verified on gcc, clang and msvc). Added a whole bunch of static asserts in ReactorUnitTests.cpp to sanity check the templates. Bug: b/131914569 Change-Id: I3267354d6a3f68545079365a657757969ec0047d Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/30455 Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by:
Ben Clayton <bclayton@google.com> Reviewed-by:
Nicolas Capens <nicolascapens@google.com>
351be42e
×