From patchwork Mon Oct 31 14:47:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 80212 Delivered-To: patch@linaro.org Received: by 10.80.142.83 with SMTP id 19csp196612edx; Mon, 31 Oct 2016 08:29:57 -0700 (PDT) X-Received: by 10.55.26.156 with SMTP id l28mr25523903qkh.164.1477927797662; Mon, 31 Oct 2016 08:29:57 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 4si17925268qtm.110.2016.10.31.08.29.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 31 Oct 2016 08:29:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:36325 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1EX6-0003cW-W7 for patch@linaro.org; Mon, 31 Oct 2016 11:29:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1Dsa-0007bt-1y for qemu-devel@nongnu.org; Mon, 31 Oct 2016 10:48:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1DsX-0007BX-C0 for qemu-devel@nongnu.org; Mon, 31 Oct 2016 10:48:04 -0400 Received: from mail-qk0-x231.google.com ([2607:f8b0:400d:c09::231]:34312) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c1DsX-0007BO-8K for qemu-devel@nongnu.org; Mon, 31 Oct 2016 10:48:01 -0400 Received: by mail-qk0-x231.google.com with SMTP id q130so44246779qke.1 for ; Mon, 31 Oct 2016 07:48:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=T1OiCJyGdZP7pK448osOtc3ov468Jm63AExzKVodoZA=; b=bIDtKzTjzjlfU0yyg+Q1HPQXuKexj63WGBt9ceQaHQNVN681kzLVuMptsiPcTstgWj tqXDn6oYRzXtk1ujWqJY6J3WHzp3VoNLuUrkvtzzE66NWPsWBx0MW15eKx+TBKmhAG39 mnzqihU5fO1GSU7ORO8Aom+uyFixoDy7AxuXWsU0z9+gLX78fcjCy6WsMC8eaIRGGUyB UqgAdvCA/+jtp3E7/9NHvcgR6utIZLdwdrKhxiDsRJwiI3KWzkrO/MinUpKw06fEUXl8 q+LclDpu1fkMUbN4mR4up1QjafOO3ZoUHP9hUQlhDCxdxeBM0fUIqVf0y5Z5nFN0IKO5 pyxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=T1OiCJyGdZP7pK448osOtc3ov468Jm63AExzKVodoZA=; b=eyHjsHSybhf4LE1J2LhAadiIBf9lThgCJJuuMR9a6xmoSw6ttZgLGOCp3UcXxmuoEO zYng5hbxAj/MEx9dkZ+eda7FB5NtOkwYWwJgacavHL48jkFWKeQaJHK0+5vBE62L9FPn DjIaz+7hx4oPa8Rk/bB/ImNmllgCTRhVlMxo3VLG9aKsKbYIZAO8diBQNQAMbUOLQiL1 A1q2d1e8Vr5sUHJPYAQeARnXNEwsp9FA3ukQ2w/2s6p/9bPeLuJHV4S/gol4oVx0FBs+ PqBp5qsSXmTvQPyzTWC9oNZcx5R8ghwadBudZz937ZWJxhyi3W+wLU/QYY3IrrokyHu6 17gw== X-Gm-Message-State: ABUngvcU9jNLiyN9ysNLRMxIr5PxShFYFbWSHuclI4sKezJ89hiQsYO2zPcMX4wVOc9WUw== X-Received: by 10.55.70.77 with SMTP id t74mr27338245qka.78.1477925280391; Mon, 31 Oct 2016 07:48:00 -0700 (PDT) Received: from bigtime.twiddle.net.com ([64.134.26.173]) by smtp.gmail.com with ESMTPSA id k48sm13394449qtc.22.2016.10.31.07.47.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Oct 2016 07:48:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 31 Oct 2016 08:47:32 -0600 Message-Id: <1477925253-17772-9-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477925253-17772-1-git-send-email-rth@twiddle.net> References: <1477925253-17772-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c09::231 Subject: [Qemu-devel] [PULL for-2.8 8/9] tcg/tcg.h: Improve documentation of TCGv_i32 etc types X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell The typedefs we use for the TCGv_i32, TCGv_i64 and TCGv_ptr types are somewhat confusing, because we define them as pointers to structs, but the structs themselves are never defined. Explain in the comments a bit more clearly why this is OK and what is going on under the hood. Signed-off-by: Peter Maydell Message-Id: <1477067922-26202-1-git-send-email-peter.maydell@linaro.org> Signed-off-by: Richard Henderson --- tcg/tcg.h | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/tcg/tcg.h b/tcg/tcg.h index b34b5fb..af32620 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -376,14 +376,36 @@ static inline unsigned get_alignment_bits(TCGMemOp memop) typedef tcg_target_ulong TCGArg; -/* Define a type and accessor macros for variables. Using pointer types - is nice because it gives some level of type safely. Converting to and - from intptr_t rather than int reduces the number of sign-extension - instructions that get implied on 64-bit hosts. Users of tcg_gen_* don't - need to know about any of this, and should treat TCGv as an opaque type. - In addition we do typechecking for different types of variables. TCGv_i32 - and TCGv_i64 are 32/64-bit variables respectively. TCGv and TCGv_ptr - are aliases for target_ulong and host pointer sized values respectively. */ +/* Define type and accessor macros for TCG variables. + + TCG variables are the inputs and outputs of TCG ops, as described + in tcg/README. Target CPU front-end code uses these types to deal + with TCG variables as it emits TCG code via the tcg_gen_* functions. + They come in several flavours: + * TCGv_i32 : 32 bit integer type + * TCGv_i64 : 64 bit integer type + * TCGv_ptr : a host pointer type + * TCGv : an integer type the same size as target_ulong + (an alias for either TCGv_i32 or TCGv_i64) + The compiler's type checking will complain if you mix them + up and pass the wrong sized TCGv to a function. + + Users of tcg_gen_* don't need to know about any of the internal + details of these, and should treat them as opaque types. + You won't be able to look inside them in a debugger either. + + Internal implementation details follow: + + Note that there is no definition of the structs TCGv_i32_d etc anywhere. + This is deliberate, because the values we store in variables of type + TCGv_i32 are not really pointers-to-structures. They're just small + integers, but keeping them in pointer types like this means that the + compiler will complain if you accidentally pass a TCGv_i32 to a + function which takes a TCGv_i64, and so on. Only the internals of + TCG need to care about the actual contents of the types, and they always + box and unbox via the MAKE_TCGV_* and GET_TCGV_* functions. + Converting to and from intptr_t rather than int reduces the number + of sign-extension instructions that get implied on 64-bit hosts. */ typedef struct TCGv_i32_d *TCGv_i32; typedef struct TCGv_i64_d *TCGv_i64;