[LLVMdev] Type safe MVT::ValueType

Duncan Sands baldrick at free.fr
Thu Jun 5 13:38:03 PDT 2008


I would like to apply the attached patch which
changes MVT::ValueType (currently a uint32_t) into
a one-element struct (the element being a uint32_t).
This makes it harder to misuse MVT::ValueType.  Thanks
to this patch I found two cases in which the arguments
to DAG.getConstant were inverted and one in which
getStore was being passed an ValueType for the "volatile"
argument.  When I first started on this patch a few months
ago I found several other similar examples which I fixed
at the time.  The other reason for applying it is that
it gives better control over how the type is used, for
example the DAG combiner regularly compares value types
using "<" but these are wrong for apints.  I plan to fix
all these kinds of issues once this patch is in.
The struct is named MVT so also plays the role previously
played by the namespace.
This means that MVT::ValueType -> MVT, and rather than
writing MVT::getBitSize(VT) you write VT.getBitSize().
If it passes testing I plan to commit it quickly because
this kind of massive patch bitrots fast.  So if you have
any objections please make them known now!
Tests with llvm-g++ show that the new type is a POD.  I will
check before committing that it doesn't slow codegen down.
This patch is not supposed to change functionality, but
it might because a few pieces of target code will now assert
if they get an extended value type, while they wouldn't
before.  I think they are supposed to only get simple value
types...

Duncan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vstruct.diff
Type: text/x-diff
Size: 678527 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080605/15ffffae/attachment.diff>


More information about the llvm-dev mailing list