[clang] [flang] [flang] Add UNSIGNED (PR #113504)

via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 25 01:13:00 PDT 2024


================
@@ -400,6 +400,69 @@ constexpr TypeBuilderFunc getModel<bool &>() {
     return fir::ReferenceType::get(f(context));
   };
 }
+template <>
+constexpr TypeBuilderFunc getModel<unsigned short>() {
+  return getModel<short>();
----------------
jeanPerier wrote:

> The existing code does not distinguish unsigned int from signed int
Oh, I see.

That is likely just because only the short case is likely problematic. The [code dealing with target specific aspects](https://github.com/llvm/llvm-project/blob/ed6ddffb583beb450c4b0e1747ccd14f7e063105/flang/lib/Optimizer/CodeGen/Target.cpp#L113 ) that adds signext/zeroext is only triggered for integer types strictly smaller that the `int` type.

I think I would favor things being consistent and having the unsigned aspect always set here and leave it up to the target aspects to do whatever is needed when generating the LLVM IR (that does not have an unsigned integer type, just specific operations and integer extension attributes).

https://github.com/llvm/llvm-project/pull/113504


More information about the cfe-commits mailing list