From patchwork Thu Sep 28 13:29:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Ball X-Patchwork-Id: 146115 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3313694vqu; Thu, 28 Sep 2023 06:31:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHUt3rGkymAeGdWHXagYmSG0TWIzO+N5gskNV3XyB7XxnANfxIwOg+lKzoCJ/x13yfN5P3c X-Received: by 2002:a17:907:8692:b0:9ad:e62c:4517 with SMTP id qa18-20020a170907869200b009ade62c4517mr1456198ejc.34.1695907882094; Thu, 28 Sep 2023 06:31:22 -0700 (PDT) Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id l12-20020a170906078c00b00993ebae9929si16181461ejc.708.2023.09.28.06.31.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 06:31:22 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=jl+XoRFd; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=jl+XoRFd; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4871038654A3 for ; Thu, 28 Sep 2023 13:31:13 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2063.outbound.protection.outlook.com [40.107.21.63]) by sourceware.org (Postfix) with ESMTPS id 7FC753858D20 for ; Thu, 28 Sep 2023 13:30:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7FC753858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vijm2qySmNM1g3JY5xSJ+QkWNqOUVWPLbcq86x29ESc=; b=jl+XoRFdjtvL1mQEilbnWahBGhrhR2Tx71TpliOiuEH2lfrZpBg9sN7DeeLsGYrgpY9H8frCOZbtTOR3W8PngeUzT1DMIRDXLWx5xpTFsGLNpCocTP7M0QYt2ofbHEcdiAaPg0/Wp7tTvfcUSAiCZGIOjMFbhtX+jVBVNlUucQw= Received: from DB8PR03CA0035.eurprd03.prod.outlook.com (2603:10a6:10:be::48) by AS8PR08MB8875.eurprd08.prod.outlook.com (2603:10a6:20b:5b7::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Thu, 28 Sep 2023 13:30:45 +0000 Received: from DBAEUR03FT005.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:be:cafe::99) by DB8PR03CA0035.outlook.office365.com (2603:10a6:10:be::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.21 via Frontend Transport; Thu, 28 Sep 2023 13:30:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT005.mail.protection.outlook.com (100.127.142.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.25 via Frontend Transport; Thu, 28 Sep 2023 13:30:44 +0000 Received: ("Tessian outbound 6d14f3380669:v211"); Thu, 28 Sep 2023 13:30:44 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: a99f246f08777e10 X-CR-MTA-TID: 64aa7808 Received: from b8b3f2c9b942.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3DF0B10D-FBA1-441F-8862-4B2D7483C15A.1; Thu, 28 Sep 2023 13:30:08 +0000 Received: from EUR02-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b8b3f2c9b942.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 28 Sep 2023 13:30:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XXXKlKycmL2T0Fnoy8ftNdT6sQBgtVtwOXKdvJOHMy4LwBbxSENgBrUEXYWlI6alnBqYzKAnvrMbFPIRvOd5j6Xc39qpzr13N7hd6q9xWDPhKghdY3JLQQG7AxkBS3Od5kfHWVCqbCQfMuq+OgI6wvGHO4noBbyAmn/RHn35djDXu7nD0bQONhgrrH/MYdnbLMyl1CK4q8Ei5Jq1rbDk6DpDiTcKef3lEYaUUuqe1lOx4lEyxz/TuZiyUe9+UNrAQBz5ru74QfSTk0YR1eGZDEc5aTFI9buxfNykxPu/PRGbk5bAraRgUw/tic0Nk9WgGFw2TSmunYgomnQMOCg9QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vijm2qySmNM1g3JY5xSJ+QkWNqOUVWPLbcq86x29ESc=; b=K/NZsrHZ+C5KH7+T60Wa/cpjrNpP+DTI5VDiJsjGm9cDCjEnTeFiMAnPO+czCUF3acD88gFnzMNSIWxmgxJxx1NaTgpFDK0r8lCqjpNdfM4PMj8p9zRWJH26LwEN5NQpc+MPnMOxcO+9ybz04NCMWJ6dNrHH0lKK/D+1AzE14EHYCFCuyS4nxpEi760g9UG0ktp7Z837EOscsQb/fcLv2q/PpGGi4fXqzbUFN2cxkI6QklFnWn4c6M22pLmrD3FCqxeb+kxyGxRfAR6YKmZ/SDl2NU3F1a6mCuS0Nr2CeaYgPD4Yh/5OSicB6ysshyQOao70Bu4kkoC1+QEq+7JDKw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vijm2qySmNM1g3JY5xSJ+QkWNqOUVWPLbcq86x29ESc=; b=jl+XoRFdjtvL1mQEilbnWahBGhrhR2Tx71TpliOiuEH2lfrZpBg9sN7DeeLsGYrgpY9H8frCOZbtTOR3W8PngeUzT1DMIRDXLWx5xpTFsGLNpCocTP7M0QYt2ofbHEcdiAaPg0/Wp7tTvfcUSAiCZGIOjMFbhtX+jVBVNlUucQw= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from DB9PR08MB6957.eurprd08.prod.outlook.com (2603:10a6:10:2bc::10) by AS8PR08MB8327.eurprd08.prod.outlook.com (2603:10a6:20b:56e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.20; Thu, 28 Sep 2023 13:30:05 +0000 Received: from DB9PR08MB6957.eurprd08.prod.outlook.com ([fe80::466d:46ab:e188:aead]) by DB9PR08MB6957.eurprd08.prod.outlook.com ([fe80::466d:46ab:e188:aead%3]) with mapi id 15.20.6813.027; Thu, 28 Sep 2023 13:30:05 +0000 Message-ID: <0058d74e-70ba-9b8e-adef-2df01569885d@arm.com> Date: Thu, 28 Sep 2023 14:29:28 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 From: Richard Ball Content-Language: en-US To: "gcc-patches@gcc.gnu.org" , Richard Earnshaw , Kyrylo Tkachov , Nick Clifton , ramana.gcc@gmail.com Subject: [PATCH 2/2] arm: move the switch tables for Arm to the RO data section. X-ClientProxiedBy: LO2P265CA0399.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:f::27) To DB9PR08MB6957.eurprd08.prod.outlook.com (2603:10a6:10:2bc::10) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: DB9PR08MB6957:EE_|AS8PR08MB8327:EE_|DBAEUR03FT005:EE_|AS8PR08MB8875:EE_ X-MS-Office365-Filtering-Correlation-Id: a657c2ad-69c7-4562-da0c-08dbc0271e62 X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 0eRT1RUFmNLXp3bqrHD7bhhwz7fjziArdrFYcxb20fTaLEIFbKbZcli7jlGdrQG/1FkmhHfT9tuAw91Y2cvZn11+znhcQAqwwMQ+E0KI0ggubiEpi3io38cFsF7GM01KGCf8PZE6AgONZ53KA0JqYGgn4kU6u9idBOa3qX7/2QtSTIOqhwU1lGA5Wo5uyWhMe1Ftlran3ntYCrLa0ARQeTkn8tDg+haiCSp4g/Bh8mDcklHwV+QFnTitUgwNC7w6gxCbeOilyS/JXTItC9JQ2rWgsoho9uwmCcFxDOyz+8wUQJ6RQbS7DOEDDFVHdTQxopkA44HqBy48a/BYDZoZYXYr5T9azAX2267FRxBQDiHRPHvjTT3O+bo/lqOdql3MFvIzd6Q/7Mrs/q3GNpnaB1BpdgWQigcuRmTIHGXF6etkUYO26IEXPAWWgJ3t0Dz5IMIRgAFm5AYdp0/OOfs9vF45GZtviiH6moQCUPUPEEzZV60fs39NMjuaN6Mwc5J11j3A+12HOvhyihaOuC25Q644y4OGxvBK/eG7P5XQTNLckjsCXKBQfCjU6h831kDe82w+F50VK6FwFjHZdbStBDUjafiYQk4gazBD6PXgbB782JL+oaExy9jmT9cMOxux7rz8CKn59po4HovzwSn6dg== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR08MB6957.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(396003)(376002)(136003)(366004)(346002)(39860400002)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(6486002)(6506007)(6666004)(36756003)(33964004)(66476007)(2906002)(110136005)(8936002)(8676002)(316002)(235185007)(44832011)(66946007)(41300700001)(5660300002)(26005)(66556008)(6512007)(38100700002)(86362001)(478600001)(2616005)(31696002)(84970400001)(31686004)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8327 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT005.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 06e7c2b3-acf9-49ac-9704-08dbc0270703 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MffBIgoVaFFhavIBk8vQHY5lENdwFo5p+wUORTcczFEsGyfM3THCkMP2+NAOKGH3gLWExhnD3j94l+gXIDzrNbDqH0NfsNs8dcYvl178QpnBycPUPf/mlxKvxBWq7/OghiVveBDskujt4ugt4wRQ4CbEc4IoXxZIpK1cInLpL+FFBUR35AYtbqPAi7t7WQoNLCjXDtYfg4swvrrcsZCrqUDWqRDorSpuYO00CCazRVkDZy6dhfZaYJChd5t67L0o1nsZkUZEgEpRtK52T3/At/X4x3BNungKfLGhqbHdv/wQgoha12CCGEjhRHXtz/WMM1zjXv+fg0rQK8b2VJeeSCZJaq/Y2TyEyxYntcCdVYo8npYUqNKVdhJ+humy6laTKeJCNbTuodUvjfUN5UxBWqiqTHAIZtPKTZz2o32qmgu2rWB+zicWDsoMUo+GBCU8zDVVGkOBzRZzvDPoTk6jo6pQ0ocopv7l5itCZEqCc47/ePkQvmW40RVh8rCSbvdvxlAurwGWp8XP1zRMym98Otn/iu/hLECzQEwjPi6yJT9LuEUOqsRr4CqvzS/j8uH4kiFkIHcadnmmUFrrLhM8aS+ZNoULU1zy3xbTZ7w4AVIAuisAJ5I7wU1JTU288ZHfcYak3UHejmJA31DczZjWTgbuIj+LSkTkxz3+ylDPMAMqdZ/weAKMg7fG0UAfEeFi5RmsK3E7XLStStNbznzm6ponTlUKJMpSwmOJZ8h7nNXbGdsmP3wNtwarDQ5gNPWp X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230031)(4636009)(376002)(136003)(346002)(396003)(39860400002)(230922051799003)(451199024)(186009)(64100799003)(1800799009)(82310400011)(36840700001)(40470700004)(46966006)(110136005)(8676002)(316002)(41300700001)(31686004)(84970400001)(235185007)(70206006)(70586007)(40480700001)(6512007)(8936002)(2906002)(44832011)(478600001)(40460700003)(6666004)(26005)(5660300002)(6486002)(33964004)(47076005)(6506007)(81166007)(336012)(2616005)(86362001)(36860700001)(356005)(82740400003)(31696002)(36756003)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 13:30:44.8953 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a657c2ad-69c7-4562-da0c-08dbc0271e62 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT005.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8875 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_LOTSOFHASH, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778288303333635354 X-GMAIL-MSGID: 1778288303333635354 Follow up patch to arm: Use deltas for Arm switch tables This patch moves the switch tables for Arm from the .text section into the .rodata section. gcc/ChangeLog: * config/arm/aout.h: Change to use the Lrtx label. * config/arm/arm.h (CASE_VECTOR_PC_RELATIVE): Remove arm targets from (!target_pure_code) condition. (ADDR_VEC_ALIGN): Add align for tables in rodata section. * config/arm/arm.cc (arm_output_casesi): Alter the function to include .Lrtx label and remove adr instructions. * config/arm/arm.md (arm_casesi_internal): Use force_reg to generate ldr instructions that would otherwise be out of range, and change rtl to accommodate force reg. Additionally remove unnecessary register temp. (casesi): Remove pure code check for Arm. * config/arm/elf.h (JUMP_TABLES_IN_TEXT_SECTION): Remove arm targets from JUMP_TABLES_IN_TEXT_SECTION definition. gcc/testsuite/ChangeLog: * gcc.target/arm/arm-switchstatement.c: Alter the tests to change adr instruction to ldr. diff --git a/gcc/config/arm/aout.h b/gcc/config/arm/aout.h index 6a4c8da5f6d5a1695518f42830b9d045888eeed6..49896bb962081a5ee4b5328029813c681c489a9e 100644 --- a/gcc/config/arm/aout.h +++ b/gcc/config/arm/aout.h @@ -187,16 +187,16 @@ switch (GET_MODE (body)) \ { \ case E_QImode: \ - asm_fprintf (STREAM, "\t.byte\t(%LL%d-%LL%d-4)/4\n", \ + asm_fprintf (STREAM, "\t.byte\t(%LL%d-%LLrtx%d-4)/4\n", \ VALUE, REL); \ break; \ case E_HImode: \ - asm_fprintf (STREAM, "\t.2byte\t(%LL%d-%LL%d-4)/4\n", \ + asm_fprintf (STREAM, "\t.2byte\t(%LL%d-%LLrtx%d-4)/4\n", \ VALUE, REL); \ break; \ case E_SImode: \ if (flag_pic) \ - asm_fprintf (STREAM, "\t.word\t%LL%d-%LL%d-4\n", \ + asm_fprintf (STREAM, "\t.word\t%LL%d-%LLrtx%d-4\n", \ VALUE, REL); \ else \ asm_fprintf (STREAM, "\t.word\t%LL%d\n", VALUE); \ diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index 3063e3489094f04ecf03a52952c185d4a75da645..ba61cf6fb9e4969776b49b499ce2205a940385d0 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -2092,10 +2092,10 @@ enum arm_auto_incmodes for the index in the tablejump instruction. */ #define CASE_VECTOR_MODE Pmode -#define CASE_VECTOR_PC_RELATIVE ((TARGET_ARM || TARGET_THUMB2 \ +#define CASE_VECTOR_PC_RELATIVE (TARGET_ARM || ((TARGET_THUMB2 \ || (TARGET_THUMB1 \ && (optimize_size || flag_pic))) \ - && (!target_pure_code)) + && (!target_pure_code))) #define CASE_VECTOR_SHORTEN_MODE(min, max, body) \ @@ -2301,8 +2301,14 @@ extern int making_const_table; asm_fprintf (STREAM, "\tpop {%r}\n", REGNO); \ } while (0) -#define ADDR_VEC_ALIGN(JUMPTABLE) \ - ((TARGET_THUMB && GET_MODE (PATTERN (JUMPTABLE)) == SImode) ? 2 : 0) +/* If the switch table is in the code segment, additional alignment is + needed for Thumb SImode tables. Otherwise, tables in RO data have + natural alignment. */ +#define ADDR_VEC_ALIGN(TABLE) \ + (JUMP_TABLES_IN_TEXT_SECTION \ + ? ((TARGET_THUMB && GET_MODE (PATTERN (TABLE)) == SImode) ? 2 : 0) \ + : (exact_log2 (GET_MODE_ALIGNMENT (GET_MODE (PATTERN (TABLE))) \ + / BITS_PER_UNIT))) /* Alignment for case labels comes from ADDR_VEC_ALIGN; avoid the default alignment from elfos.h. */ diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index 4e5e6997ed555372683e01b2aff5c25265f4e50c..c3a5ef274276cdef1b41690eb0ad7fd4f4218ecf 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -30469,44 +30469,58 @@ arm_output_iwmmxt_tinsr (rtx *operands) const char * arm_output_casesi (rtx *operands) { + char buf[100]; + char label[100]; rtx diff_vec = PATTERN (NEXT_INSN (as_a (operands[2]))); - gcc_assert (GET_CODE (diff_vec) == ADDR_DIFF_VEC); - output_asm_insn ("cmp\t%0, %1", operands); output_asm_insn ("bhi\t%l3", operands); + ASM_GENERATE_INTERNAL_LABEL (label, "Lrtx", CODE_LABEL_NUMBER (operands[2])); switch (GET_MODE (diff_vec)) { case E_QImode: - output_asm_insn ("adr\t%4, %l2", operands); if (ADDR_DIFF_VEC_FLAGS (diff_vec).offset_unsigned) - output_asm_insn ("ldrb\t%4, [%4, %0]", operands); + output_asm_insn ("ldrb\t%4, [%5, %0]", operands); else - output_asm_insn ("ldrsb\t%4, [%4, %0]", operands); - return "add\t%|pc, %|pc, %4, lsl #2"; - + output_asm_insn ("ldrsb\t%4, [%5, %0]", operands); + output_asm_insn ("add\t%|pc, %|pc, %4, lsl #2", operands);; + break; case E_HImode: - output_asm_insn ("adr\t%4, %l2", operands); - output_asm_insn ("add\t%4, %4, %0", operands); - if (ADDR_DIFF_VEC_FLAGS (diff_vec).offset_unsigned) - output_asm_insn ("ldrh\t%4, [%4, %0]", operands); - else - output_asm_insn ("ldrsh\t%4, [%4, %0]", operands); - return "add\t%|pc, %|pc, %4, lsl #2"; - + if (REGNO (operands[4]) != REGNO (operands[5])) + { + output_asm_insn ("add\t%4, %0, %0", operands); + if (ADDR_DIFF_VEC_FLAGS (diff_vec).offset_unsigned) + output_asm_insn ("ldrh\t%4, [%5, %4]", operands); + else + output_asm_insn ("ldrsh\t%4, [%5, %4]", operands); + } + else + { + output_asm_insn ("add\t%4, %5, %0", operands); + if (ADDR_DIFF_VEC_FLAGS (diff_vec).offset_unsigned) + output_asm_insn ("ldrh\t%4, [%4, %0]", operands); + else + output_asm_insn ("ldrsh\t%4, [%4, %0]", operands); + } + output_asm_insn ("add\t%|pc, %|pc, %4, lsl #2", operands); + break; case E_SImode: if (flag_pic) { - output_asm_insn ("adr\t%4, %l2", operands); - output_asm_insn ("ldr\t%4, [%4, %0, lsl #2]", operands); - return "add\t%|pc, %|pc, %4"; + output_asm_insn ("ldr\t%4, [%5, %0, lsl #2]", operands); + output_asm_insn ("add\t%|pc, %|pc, %4", operands); } - output_asm_insn ("adr\t%4, %l2", operands); - return "ldr\t%|pc, [%4, %0, lsl #2]"; - + else + { + output_asm_insn ("ldr\t%|pc, [%5, %0, lsl #2]", operands); + } + break; default: gcc_unreachable (); } + assemble_label (asm_out_file, label); + output_asm_insn ("nop;", operands); + return ""; } /* Output a Thumb-1 casesi dispatch sequence. */ diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md index 0b2eb4bce92bb7e8b1ca0c5a04b1a52e9c16b64a..810d862df7f343f2e4f5f11af3f6061b41ca3606 100644 --- a/gcc/config/arm/arm.md +++ b/gcc/config/arm/arm.md @@ -9514,7 +9514,8 @@ (match_operand:SI 2 "const_int_operand") ; total range (match_operand:SI 3 "" "") ; table label (match_operand:SI 4 "" "")] ; Out of range label - "(TARGET_32BIT || optimize_size || flag_pic) && !target_pure_code" + "TARGET_ARM || ((TARGET_THUMB2 || optimize_size || flag_pic) && + (!target_pure_code))" " { enum insn_code code; @@ -9557,13 +9558,13 @@ (label_ref:SI (match_operand 3 "")))) (clobber (reg:CC CC_REGNUM)) (clobber (match_scratch:SI 5)) - (clobber (match_scratch:SI 6)) (use (label_ref:SI (match_operand 2 "")))])] "TARGET_ARM" { + rtx tmp = force_reg (SImode, gen_rtx_LABEL_REF (SImode, operands[2])); operands[4] = gen_rtx_MULT (SImode, operands[0], GEN_INT (4)); operands[4] = gen_rtx_PLUS (SImode, operands[4], - gen_rtx_LABEL_REF (SImode, operands[2])); + tmp); operands[4] = gen_rtx_MEM (SImode, operands[4]); MEM_READONLY_P (operands[4]) = 1; MEM_NOTRAP_P (operands[4]) = 1; @@ -9575,12 +9576,11 @@ (leu (match_operand:SI 0 "s_register_operand" "r") (match_operand:SI 1 "arm_rhs_operand" "rI")) (mem:SI (plus:SI (mult:SI (match_dup 0) (const_int 4)) - (label_ref:SI (match_operand 2 "" "")))) + (match_operand:SI 5 "s_register_operand" "r"))) (label_ref:SI (match_operand 3 "" "")))) (clobber (reg:CC CC_REGNUM)) - (clobber (match_scratch:SI 4 "=&r")) - (clobber (match_scratch:SI 5 "=r")) - (use (label_ref:SI (match_dup 2)))])] + (clobber (match_scratch:SI 4 "=r")) + (use (label_ref:SI (match_operand 2 "")))])] "TARGET_ARM" { return arm_output_casesi (operands); diff --git a/gcc/config/arm/elf.h b/gcc/config/arm/elf.h index 5766cb4a9888512889334c48ccfbe46e9980f800..3e878f21350a008c363618599058f33ff759a5fa 100644 --- a/gcc/config/arm/elf.h +++ b/gcc/config/arm/elf.h @@ -91,11 +91,11 @@ /* Define this macro if jump tables (for `tablejump' insns) should be output in the text section, along with the assembler instructions. Otherwise, the readonly data section is used. */ -/* We put ARM and Thumb-2 jump tables in the text section, because it makes - the code more efficient, but for Thumb-1 it's better to put them out of +/* We put Thumb-2 jump tables in the text section, because it makes + the code more efficient, but for Thumb-1 and ARM it's better to put them out of band unless we are generating compressed tables. */ #define JUMP_TABLES_IN_TEXT_SECTION \ - ((TARGET_32BIT || (TARGET_THUMB && (optimize_size || flag_pic))) \ + ((TARGET_THUMB2 || (TARGET_THUMB && (optimize_size || flag_pic))) \ && !target_pure_code) #ifndef LINK_SPEC diff --git a/gcc/testsuite/gcc.target/arm/arm-switchstatement.c b/gcc/testsuite/gcc.target/arm/arm-switchstatement.c index a7aa9d45c7634db6c8192072019e497db969b681..803731c479c66e9e684cae532a6071335c042f0e 100644 --- a/gcc/testsuite/gcc.target/arm/arm-switchstatement.c +++ b/gcc/testsuite/gcc.target/arm/arm-switchstatement.c @@ -53,9 +53,10 @@ inline void SIFunction (const char* flag) /* **QImode_test: ** ... -** adr (r[0-9]+), .L[0-9]+ -** ldrb \1, \[\1, r[0-9]+\] -** add pc, pc, \1, lsl #2 +** ldr (r[0-9]+), .L[0-9]+ +** ... +** ldrb (r[0-9]+), \[\1, r[0-9]+\] +** add pc, pc, \2, lsl #2 ** ... */ __attribute__ ((noinline)) __attribute__ ((noclone)) const char* QImode_test(enum z x) @@ -77,10 +78,11 @@ __attribute__ ((noinline)) __attribute__ ((noclone)) const char* QImode_test(enu /* **HImode_test: ** ... -** adr (r[0-9]+), .L[0-9]+ -** add \1, \1, (r[0-9]+) -** ldrh \1, \[\1, \2\] -** add pc, pc, \1, lsl #2 +** ldr (r[0-9]+), .L[0-9]+ +** ... +** add r[0-9]+, r[0-9]+, r[0-9]+ +** ldrh (r[0-9]+), \[r[0-9]+, r[0-9]+] +** add pc, pc, \2, lsl #2 ** ... */ __attribute__ ((noinline)) __attribute__ ((noclone)) const char* HImode_test(enum z x) @@ -102,7 +104,8 @@ __attribute__ ((noinline)) __attribute__ ((noclone)) const char* HImode_test(enu /* **SImode_test: ** ... -** adr (r[0-9]+), .L[0-9]+ +** ldr (r[0-9]+), .L[0-9]+ +** ... ** ldr pc, \[\1, r[0-9]+, lsl #2\] ** ... */ @@ -125,10 +128,11 @@ __attribute__ ((noinline)) __attribute__ ((noclone)) const char* SImode_test(enu /* **backwards_branch_test: ** ... -** adr (r[0-9]+), .L[0-9]+ -** add \1, \1, (r[0-9]+) -** ldrsh \1, \[\1, \2\] -** add pc, pc, \1, lsl #2 +** ldr (r[0-9]+), .L[0-9]+ +** ... +** add r[0-9]+, r[0-9]+, r[0-9]+ +** ldrsh (r[0-9]+), \[r[0-9]+, r[0-9]+] +** add pc, pc, \2, lsl #2 ** ... */ __attribute__ ((noinline)) __attribute__ ((noclone)) const char* backwards_branch_test(enum z x, int flag)