[LLVMdev] Question about documentation of BitCast CExps.

Jesper Louis Andersen jesper.louis.andersen at gmail.com
Sat Feb 28 06:22:05 PST 2009


In the documentation at [http://llvm.org/docs/LangRef.html], we have
the section [#aggregateconstants] telling us that the aggregate
constants are:

  * Structure constants
  * Array constants
  * Vector constants
  * Zeroinitialization

However, in [#constantexprs] we have a bitcast(CST, TYPE) operator
with the documentation (emphasis by me):

Convert a constant, CST, to another TYPE. The size of CST and TYPE
must be identical (same number of bits). The conversion is done as if
the CST value was stored to memory and read back as TYPE. In other
words, no bits change with this operator, just the type. {{{This can
be used for conversion of vector types to any other type, as long as
they have the same bit width}}}. For pointers it is only valid to cast
to another pointer type. {{{It is not valid to bitcast to or from an
aggregate type.}}}

The first emphasis states that it is possible to use the bitcast
operation for conversion of vector types. However, the second emphasis
says that this is not valid (A vector is an aggregate type). So my
questions are:

What is right?
Is this a mistake?
Am I reading this wrong in any way? If so, where?

The reason I am asking is because I am in the process of implementing
a rudimentary type-checker phase for LLVM in Standard ML. It is mostly
done because it is a tremendous way to learn about the finer details
of the language. I am forced to think and know details about LLVM
because of the process, so hence my question.

-- 
J.



More information about the llvm-dev mailing list