vzakhari wrote:

> It would be better to have the types that are available on the device declare 
> themselves so in their declarations via a member or (better) inherited trait.

Like this. I will add the type trait for those types that are available on the 
device.

> The big variant union in `IoStatementState` could omit the host-only options 
> when compiled for the device.

I am not sure what you are suggesting.  I cannot comment out (e.g. with 
`RT_DEVICE_OUTPUT` check) the members of `std::variant<...> u_` union, because 
this will require commenting out all class declarations that try to explicitly 
access/emplace an instance of the commented out class into the union member. 
For example,
```
class NoUnitIoStatementState : public IoStatementBase {
...
  template <typename A>
  NoUnitIoStatementState(A &stmt, const char *sourceFile = nullptr,
      int sourceLine = 0, int badUnitNumber = -1)
      : IoStatementBase{sourceFile, sourceLine}, ioStatementState_{stmt},
        badUnitNumber_{badUnitNumber} {}
...
};

class NoopStatementState : public NoUnitIoStatementState {
public:
  NoopStatementState(
      const char *sourceFile = nullptr, int sourceLine = 0, int unitNumber = -1)
      : NoUnitIoStatementState{*this, sourceFile, sourceLine, unitNumber} {}
...
};
```

`ioStatementState_{stmt}` is invalid if the union does not have 
`NoUnitIoStatementState` variant. There are more examples like this, and there 
is a lot of code that will need to be commented out for the device compilation 
if I modify the union declaration.  Maybe I misunderstood your comment, though.

https://github.com/llvm/llvm-project/pull/85179
_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to