[llvm-dev] Adding new a new type

Friedman, Eli via llvm-dev llvm-dev at lists.llvm.org
Mon May 14 17:00:10 PDT 2018


On 5/14/2018 4:38 PM, Jason Ott wrote:
> Ok, so I can use the structure-type to represent base or acid or 
> salts.  My next question is how union-typing works in LLVM.  After 
> reading a bit about, it's unclear to me if it is a "thing" anymore; my 
> intuition -- and poking around in the sources is that it's a "no", 
> it's been deprecated.

No, LLVM doesn't have unions; you just bitcast pointers between 
different struct types.  (In general, if you're having trouble 
understanding how to lower something to LLVM IR, it's often useful to 
use "clang -S -emit-llvm" to see what clang emits for a simple C testcase.)

> Which then means that it doesn't much matter about typing LLVM.  I can 
> pass that up to a python script and handle typing up there.

Yes, you should only use LLVM types as far as they're actually helpful.

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project



More information about the llvm-dev mailing list