Leslie Zhai via llvm-dev
2018-Jul-04 09:58 UTC
[llvm-dev] Why SI.isSigned() is not equals to E->getType()->isSignedIntegerOrEnumerationType()?
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
Friedman, Eli via llvm-dev
2018-Jul-05 19:59 UTC
[llvm-dev] Why SI.isSigned() is not equals to E->getType()->isSignedIntegerOrEnumerationType()?
On 7/4/2018 2:58 AM, Leslie Zhai via llvm-dev wrote:> 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]: > > 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.This probably indicates some sort of type mismatch in the AST (like a binary add with signed operands and an unsigned result). Expressions have a dump() method which might be helpful for debugging. -Eli -- Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Leslie Zhai via llvm-dev
2018-Jul-06 02:42 UTC
[llvm-dev] Why SI.isSigned() is not equals to E->getType()->isSignedIntegerOrEnumerationType()?
Hi Friedman, Thanks for your response! I will try dump() to debug. and I found that even if remove the assertion (monkey patch) it might failed to parse `wire` Type, so I need to find out the root cause where I dig the wrong hole, thanks for your teaching :) 在 2018年07月06日 03:59, Friedman, Eli 写道:> On 7/4/2018 2:58 AM, Leslie Zhai via llvm-dev wrote: >> 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]: >> >> 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. > > This probably indicates some sort of type mismatch in the AST (like a > binary add with signed operands and an unsigned result). Expressions > have a dump() method which might be helpful for debugging. > > -Eli >-- Regards, Leslie Zhai