[llvm-dev] Why SI.isSigned() is not equals to E->getType()->isSignedIntegerOrEnumerationType()?

Leslie Zhai via llvm-dev llvm-dev at lists.llvm.org
Wed Jul 4 02:58:09 PDT 2018


Hi LLVM developers,

I am implementing Loong Language[1] using Clang FrontEnd and LLVM 
MiddleEnd. I add `wire`[2] Builtin Type, and clang is able to parse very 
small testcase fulladder[3] but failed to work for 10+K loc RISCV E203 
project[4]:


Loongson clang version 7.0.0 
(git at github.com:Loong-Language/loong-clang.git 
8f7e826f27abbe12ea08d9563490298c38d3adc1) 
(git at github.com:Loong-Language/loong-llvm.git 
a05924fba80aa7173fce66b86d35ac2c57ad4dc4) (based on LLVM 7.0.0svn)
Target: mips64el-redhat-linux
Thread model: posix
InstalledDir: /home/zhaixiang/project/Loong-Language/loong-llvm/build/bin
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 0 0
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 0 0
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 0 0
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 0 0
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 0 0
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 0 0
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 1 1
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 1 1
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 1 1
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 1 1
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 1 1
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 1 1
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 1 1
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 1 1
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 1 1
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 1 1
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 1 1
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 1 1
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 1 1
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 1 1
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 1 1
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 0 0
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 0 0
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 0 0
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 0 0
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 0 0
DEBUG: bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, 
const clang::Expr*, clang::APValue&) 7096 1 0
clang-7: 
/home/zhaixiang/project/Loong-Language/loong-llvm/tools/clang/lib/AST/ExprConstant.cpp:7098: 
bool {anonymous}::IntExprEvaluator::Success(const llvm::APSInt&, const 
clang::Expr*, clang::APValue&): Assertion `SI.isSigned() == 
E->getType()->isSignedIntegerOrEnumerationType() && "Invalid evaluation 
result."' failed.
Stack dump:
0.    Program arguments: 
/home/zhaixiang/project/Loong-Language/loong-llvm/build/bin/clang-7 -cc1 
-triple mips64el-redhat-linux -emit-llvm -disable-free -main-file-name 
e203_core.loong -mrelocation-model pic -pic-level 1 -mthread-model posix 
-mdisable-fp-elim -fmath-errno -no-integrated-as -mconstructor-aliases 
-fuse-init-array -target-cpu mips64r2 -target-feature -noabicalls 
-target-abi n64 -mfloat-abi hard -dwarf-column-info -debugger-tuning=gdb 
-coverage-notes-file 
/home/zhaixiang/project/Loong-Language/e200_opensource/rtl/e203/core/e203_core.gcno 
-resource-dir 
/home/zhaixiang/project/Loong-Language/loong-llvm/build/lib/clang/7.0.0 
-I ../ -internal-isystem 
/usr/lib/gcc/mips64el-redhat-linux/4.9.3/../../../../include/c++/4.9.3 
-internal-isystem 
/usr/lib/gcc/mips64el-redhat-linux/4.9.3/../../../../include/c++/4.9.3/mips64el-redhat-linux 
-internal-isystem 
/usr/lib/gcc/mips64el-redhat-linux/4.9.3/../../../../include/c++/4.9.3/backward 
-internal-isystem /usr/local/include -internal-isystem 
/home/zhaixiang/project/Loong-Language/loong-llvm/build/lib/clang/7.0.0/include 
-internal-externc-isystem /include -internal-externc-isystem 
/usr/include -Werror -std=c++17 -fdeprecated-macro 
-fno-dwarf-directory-asm -fdebug-compilation-dir 
/home/zhaixiang/project/Loong-Language/e200_opensource/rtl/e203/core 
-ferror-limit 19 -fmessage-length 109 -fobjc-runtime=gcc 
-fcxx-exceptions -fexceptions -fdiagnostics-show-option 
-fcolor-diagnostics -disable-O0-optnone -o e203_core.ll -x c++ 
e203_core.loong
1.    ./e203_ifu_ifetch.loong:194:4: current parser token 'wire'
2.    ./e203_ifu_ifetch.loong:39:1: parsing struct/union/class body 
'e203_ifu_ifetch'
3.    ./e203_ifu_ifetch.loong:118:17: parsing function body 
'e203_ifu_ifetch::e203_ifu_ifetch'
4.    ./e203_ifu_ifetch.loong:118:17: in compound statement ('{}')


Why SI.isSigned() is not equals to 
E->getType()->isSignedIntegerOrEnumerationType()? please give me some 
hint, thanks a lot!

1. Hardware Description Language, heavily influenced by Verilog and VHDL 
https://github.com/Loong-Language/
2. Verilog Wire and Reg http://www.asic-world.com/tidbits/wire_reg.html
3. Full Adder is reimplemented by Loong 
https://github.com/Loong-Language/loong-toolchain/blob/master/test/fulladder.loong
4. RISCV E203 rtl is reimplemented by Loong 
https://github.com/Loong-Language/e200_opensource/blob/loong/rtl/e203/core/e203_ifu_ifetch.loong

-- 
Regards,
Leslie Zhai




More information about the llvm-dev mailing list