From patchwork Tue Mar 21 00:15:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 9635657 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A6B6860327 for ; Tue, 21 Mar 2017 00:16:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99827271CB for ; Tue, 21 Mar 2017 00:16:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E74B275A2; Tue, 21 Mar 2017 00:16:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01A2F26E4F for ; Tue, 21 Mar 2017 00:16:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755772AbdCUAQf (ORCPT ); Mon, 20 Mar 2017 20:16:35 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:36469 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755818AbdCUAQd (ORCPT ); Mon, 20 Mar 2017 20:16:33 -0400 Received: by mail-wr0-f195.google.com with SMTP id l37so20367381wrc.3 for ; Mon, 20 Mar 2017 17:16:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=a1TFT5mFEz4bPsS75W5RbRliDo9S+CSkWqT++aVV9SI=; b=nr4ZOS56v/Z7P1jgYej8o5+tR2SLuwuG4Be7OQoHIzb90FoGnMBe1bdCk6hD0lb95l IB3LvQptQtsT9s7lFxA9yWqriYF8E0ZQXAW4/32TiTXFBQVDN+9mtKY6pnzzYZRyVMKn ozdVEhEd2ran2i5OVIO5e3tPMKK9w8iZC/eR8MCxmyax3RIiBBNwYVDs804oVgb8fq3w uJ3ptolv7pJmv2otn3qkaJ1jvmZRhDlXiF1MouOpZPy7pplm721VnC0M8L4HuaS0gPAo VwdQhiw1KDv66dtzlSfhrJKgVTV9L0vzx62uYNADBU+TL4rQu2sj2Qs3DrsssU7hvbZV p2RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=a1TFT5mFEz4bPsS75W5RbRliDo9S+CSkWqT++aVV9SI=; b=FpDlkzXactAENZTsCbNIwNvYb7tbM7bcamiaBxo8mU4185tA4GqEHSkWxdkc2jGLqv nAAGiz0NKMCgvPWfTHCX0Nmp7Q+t1A16PP5uJcVaXjXANrGlpQuAC/abRQ7EEZ5Y0gpF t/s1Xuik4IA7SlkiXl17FrAEEmVCHDVs/4phs6bMnVO8dASuahaGw5GPVXJZrFm9rFoy 3koEUfLcA5MAhk8NFoJzB1V8br4AsDGi0mMttd6gDmxsHY9Z6owcV1ICOadGKdm2pK1A nKSy2NJ09pAlgKAUvephNJKLORi3viOuU8gEIEqedT87OJZ8d4gXhSyGgtr6Ie4tKPkO /EdQ== X-Gm-Message-State: AFeK/H1+xhcuBMkAz1MwyD5/KBf/hzXmbE2OxUyBZc9qK9nskLPQohXRqkUtyJ9Z0kDReg== X-Received: by 10.223.136.182 with SMTP id f51mr25963873wrf.90.1490055391166; Mon, 20 Mar 2017 17:16:31 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:8b8:5c00:403a:a805:fd41:37d2]) by smtp.gmail.com with ESMTPSA id t195sm15271172wmt.32.2017.03.20.17.16.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Mar 2017 17:16:30 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Christopher Li , Dibyendu Majumdar , Jeff Garzik , Pekka Enberg , Luc Van Oostenryck Subject: [PATCH v4 11/63] add doc about sparse's instructions/IR Date: Tue, 21 Mar 2017 01:15:15 +0100 Message-Id: <20170321001607.75169-12-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170321001607.75169-1-luc.vanoostenryck@gmail.com> References: <20170321001607.75169-1-luc.vanoostenryck@gmail.com> Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Luc Van Oostenryck --- Documentation/instructions.txt | 270 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 270 insertions(+) create mode 100644 Documentation/instructions.txt diff --git a/Documentation/instructions.txt b/Documentation/instructions.txt new file mode 100644 index 000000000..db30e52f7 --- /dev/null +++ b/Documentation/instructions.txt @@ -0,0 +1,270 @@ +This brievely describe which field of struct instruction is +used by which operation. + +== Terminator == +=== OP_RET === +Return from subroutine. +- .src : returned value (NULL if void) +- .type: type of .src + +=== OP_BR === +Unconditional branch +- .bb_true: destination basic block + +=== OP_CBR === +Conditional branch +- .cond: condition +- .type: type of .cond, must be an integral type +- .bb_true, .bb_false: destination basic blocks + +=== OP_SWITCH === +Switch / multi-branch +- .cond: condition +- .type: type of .cond, must be an integral type +- .multijmp_list: pairs of case-value - destination basic block + +=== OP_COMPUTEDGOTO === +Computed goto / branch to register +- .target: target address +- .type: type of .target FIXME +- .multijmp_list: list of possible destination basic blocks + +== Arithmetic binops == +They all follow the same signature: +- .src1, .src1: operands (types must be compatible with .target) +- .target: result of the operation +- .type: type of .target + +=== OP_ADD === +Addition. + +=== OP_SUB === +Subtraction. + +=== OP_MULU === +Multiplication (unsigned ints & floating-points) + +=== OP_MULS, === +Multiplication (signed ints) + +=== OP_DIVU === +Division (unsigned ints & floating-points) + +=== OP_DIVS, === +Division (signed ints) + +=== OP_MODU === +Modulo (unsigned division remainder, integer only) + +=== OP_MODS, === +Modulo (signed division remainder, integer only) + +=== OP_SHL === +Shift left (integer only) + +=== OP_LSR === +Logical Shift right (integer only) + +=== OP_ASR, === +Arithmetic Shift right (integer only) + +== Logical == +They all follow the same signature: +- .src1, .src2: operands (types must be compatible with .target) +- .target: result of the operation +- .type: type of .target, must be an integral type + +=== OP_AND === +=== OP_OR === +=== OP_XOR === + +== Boolean == +=== OP_AND_BOOL === +=== OP_OR_BOOL === + +== Comparison == +- .src1, .src2: operands (types must be compatible) +- .target: result of the operation (0/1 valued integer) +- .type: type of .target, must be an integral type + +=== OP_SET_EQ === +Compare equal. + +=== OP_SET_NE === +Compare not-equal. + +=== OP_SET_LE === +Compare less-than-or-equal (signed). + +=== OP_SET_GE === +Compare greater-than-or-equal (signed). + +=== OP_SET_LT === +Compare less-than (signed). + +=== OP_SET_GT === +Compare greater-than (signed). + +=== OP_SET_B === +Compare less-than (unsigned). + +=== OP_SET_A === +Compare greater-than (unsigned). + +=== OP_SET_BE === +Compare less-than-or-equal (unsigned). + +=== OP_SET_AE === +Compare greater-than-or-equal (unsigned). + +== Unary trinary ops == +=== OP_NOT === +Logical not. +- .src: operand (type must be compatible with .target) +- .target: result of the operation +- .type: type of .target, must be an integral type + +=== OP_NEG === +Arithmetic negation. +- .src: operand (type must be compatible with .target) +- .target: result of the operation +- .type: type of .target + +=== OP_COPY === +Copy (only needed after out-of-SSA). +- .src: operand (type must be compatible with .target) +- .target: result of the operation +- .type: type of .target + +=== OP_SEL === +- .src1: condition, must be of integral type +- .src2, .src3: operands (types must be compatible with .target) +- .target: result of the operation +- .type: type of .target + +== Type conversion == +They all follow the same signature: +- .src: source value +- .orig_type: type of .src +- .target: result value +- .type: type of .target + +=== OP_CAST === +Cast to unsigned integer (and to void pointer). + +=== OP_SCAST === +Cast to signed integer. + +=== OP_FPCAST === +Cast to floating-point. + +=== OP_PTRCAST === +Cast to pointer. + +== Memory == +=== OP_LOAD === +Load. +- .src: base address to load from +- .offset: address offset +- .target: loaded value +- .type: type of .target + +=== OP_STORE === +Store. +- .src: base address to store to +- .offset: address offset +- .target: value to be stored +- .type: type of .target + +=== OP_SYMADDR === +Symbol's address. +- .symbol: the symbol +- .target: symbol's address + +=== OP_SETVAL === +"Set Value" +- .val: value's expression +- .target: the value +- .type: type of .target +The expression can be an EXPR_STRING, EXPR_FVALUE or an EXPR_LABEL. + +== Other == +=== OP_PHI === +Phi-node (for SSA form). +- .phi_list: phi-operands (type must be compatible with .target) +- .target: "result" +- .type: type of .target + +=== OP_PHISOURCE === +Phi-node source. +Like OP_COPY but exclusively used to create *all* OP_PHI operands. + +=== OP_INLINED_CALL === + +=== OP_PUSH === +Push argument. +- .src: argument +- .type: type of .src + +=== OP_CALL === +Function call. +- .func: the function (can be a symbol or a "register") +- .arguments: list of the associated OP_PUSH instructions +- .target: function return value (if any) +- .type: type of .target +- .fntype: the full function type + +=== OP_SLICE === +Extract a "slice" from an aggregate. +- .base: aggregate +- .from, .len: offet @ size of the slice within the aggregate +- .target: result +- .type: type of .target + +=== OP_ASM === +Inlined assembly code. +- .string: asm template +- .asm_rules: asm constraints, rules + +== Sparse tagging (line numbers, context, whatever) == +=== OP_CONTEXT === +Currently only used for lock/unlock tracking. +- .context_expr: unused +- .increment: (1 for locking, -1 for unlocking) +- .check: (ignore the instruction if 0) + +=== OP_RANGE === +Range checking. +- .src1: value to be checked +- .src2, src3: bound of the value (must be constants?) +- .type: FIXME + +== Misc == +=== OP_ENTRY === +Function entry point (no associated semantic). + +=== OP_BADOP === +Invalid operation (should never be generated). + +=== OP_NOP === +No-op (should never be generated). + +=== OP_SNOP === +Store no-op (removed store operation). + +=== OP_LNOP === +Load no-op (removed load operation). + +=== OP_DEATHNOTE === +Annotation telling the pseudo will be death after the next +instruction (other than some other annotation, that is). + +== Unused == +=== OP_VANEXT === +=== OP_VAARG === +=== OP_MALLOC === +=== OP_FREE === +=== OP_ALLOCA === +=== OP_GET_ELEMENT_PTR === +=== OP_INVOKE === +=== OP_UNWIND ===