[CodeGen] Add MVT::isValid to replace manual validity checks. NFC.
authorAhmed Bougacha <ahmed.bougacha@gmail.com>
Wed, 7 Jan 2015 22:47:46 +0000 (22:47 +0000)
committerAhmed Bougacha <ahmed.bougacha@gmail.com>
Wed, 7 Jan 2015 22:47:46 +0000 (22:47 +0000)
commita84b573c980f53e359b751928aa2a84569ea6386
tree33e61bfb51cc6cd746cb545f32830ef945601fd0
parenta36b682c1748100427c8c193a053750fbba6d2a8
[CodeGen] Add MVT::isValid to replace manual validity checks. NFC.

Now that we have MVT::FIRST_VALUETYPE (r225362), we can provide a method
checking that the MVT is valid, that is, it's in
  [FIRST_VALUETYPE, LAST_VALUETYPE[.
This commit also uses it in a few asserts, that would previously accept
invalid MVTs, such as the default constructed -1.  In that case,
the code following those asserts would do an out-of-bounds array access.
Using MVT::isValid, those assertions fail as expected when passed
invalid MVTs.
It feels clunky to have such a validity checking function, but it's
at least better than the alternative of broken manual checks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225411 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/CodeGen/MachineValueType.h
include/llvm/Target/TargetLowering.h