evm_builtin.sol 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // RUN: --target evm --emit cfg -Onone --no-cse
  2. contract Testing {
  3. // BEGIN-CHECK: Testing::Testing::function::builtins__uint256
  4. function builtins(uint256 arg1) public view {
  5. assembly {
  6. // CHECK: ty:uint256 %a = (zext uint256 (builtin Gasleft ()))
  7. let a := gas()
  8. // CHECK: ty:uint256 %b = (sext uint256 uint160((builtin GetAddress ())))
  9. let b := address()
  10. // CHECK: ty:uint256 %c = (sext uint256 (builtin Balance (address((trunc uint160 (arg #0))))))
  11. let c := balance(arg1)
  12. // CHECK: ty:uint256 %d = (sext uint256 (builtin Balance ((builtin GetAddress ()))))
  13. let d := selfbalance()
  14. // CHECK: ty:uint256 %e = (sext uint256 uint160((builtin Sender ())))
  15. let e := caller()
  16. // CHECK: ty:uint256 %f = (sext uint256 (builtin Value ()))
  17. let f := callvalue()
  18. // CHECK: ty:uint256 %g = (zext uint256 (builtin Gasprice ()))
  19. let g := gasprice()
  20. // CHECK: ty:uint256 %h = (builtin BlockHash ((trunc uint64 (arg #0))))
  21. let h := blockhash(arg1)
  22. // CHECK: ty:uint256 %i = (sext uint256 uint160((builtin BlockCoinbase ())))
  23. let i := coinbase()
  24. // ty:uint256 %j = (zext uint256 (builtin Timestamp ()))
  25. let j := timestamp()
  26. // CHECK: ty:uint256 %k = (zext uint256 (builtin BlockNumber ()))
  27. let k := number()
  28. // CHECK: y:uint256 %l = (builtin BlockDifficulty ())
  29. let l := difficulty()
  30. // CHECK: ty:uint256 %m = (zext uint256 (builtin GasLimit ()))
  31. let m := gaslimit()
  32. // CHECK: ty:uint256 %n = (zext uint256 (builtin ExtCodeSize (address((trunc uint160 %b)))))
  33. let n := extcodesize(b)
  34. // CHECK: assert-failure
  35. invalid()
  36. }
  37. }
  38. // BEGIN-CHECK: Testing::Testing::function::test_selfdestruct__uint256
  39. function test_selfdestruct(uint256 arg1) public {
  40. assembly {
  41. // CHECK: selfdestruct address payable((trunc uint160 (arg #0)))
  42. selfdestruct(arg1)
  43. }
  44. }
  45. }