From 311c9b5a89816f94fa6f15cc821f718172fb5c03 Mon Sep 17 00:00:00 2001 From: Eric Schweitz Date: Mon, 11 Mar 2019 09:50:28 -0700 Subject: [PATCH] [flang] remove unused files Cleanup some warnings when building with clang. Original-commit: flang-compiler/f18@33cf6255d1431a8fa0a30fb4b883615de17bcbb7 Reviewed-on: https://github.com/flang-compiler/f18/pull/328 Tree-same-pre-rewrite: false --- flang/lib/FIR/afforestation.cc | 4 +- flang/lib/FIR/builder.h | 2 +- flang/lib/FIR/graph-writer.h | 2 +- flang/lib/FIR/statement.def | 172 ----------------------------------------- flang/lib/FIR/statements.h | 24 +++++- flang/lib/FIR/stmt.h | 50 ------------ 6 files changed, 25 insertions(+), 229 deletions(-) delete mode 100644 flang/lib/FIR/statement.def delete mode 100644 flang/lib/FIR/stmt.h diff --git a/flang/lib/FIR/afforestation.cc b/flang/lib/FIR/afforestation.cc index 0d942d0..cb8cf04 100644 --- a/flang/lib/FIR/afforestation.cc +++ b/flang/lib/FIR/afforestation.cc @@ -1239,10 +1239,10 @@ public: // TODO: build an expression for the allocation return nullptr; } - const AllocateInsn *CreateDeallocationValue( + AllocateInsn *CreateDeallocationValue( const parser::AllocateObject *allocateObject, const parser::DeallocateStmt *statement) { - // TODO: build an expression for the allocation + // TODO: build an expression for the deallocation return nullptr; } diff --git a/flang/lib/FIR/builder.h b/flang/lib/FIR/builder.h index da16c13..70dc72a 100644 --- a/flang/lib/FIR/builder.h +++ b/flang/lib/FIR/builder.h @@ -59,7 +59,7 @@ struct FIRBuilder { return InsertTerminator( BranchStmt::Create(condition, trueBlock, falseBlock)); } - Statement *CreateDealloc(const AllocateInsn *alloc) { + Statement *CreateDealloc(AllocateInsn *alloc) { return Insert(DeallocateInsn::Create(alloc)); } Statement *CreateExpr(const Expression *e) { diff --git a/flang/lib/FIR/graph-writer.h b/flang/lib/FIR/graph-writer.h index 812fb46..0538c91 100644 --- a/flang/lib/FIR/graph-writer.h +++ b/flang/lib/FIR/graph-writer.h @@ -82,7 +82,7 @@ private: bool isEntry_{false}; bool isExit_{false}; std::map blockIds_; - static llvm::raw_ostream * defaultOutput_; + static llvm::raw_ostream *defaultOutput_; }; } diff --git a/flang/lib/FIR/statement.def b/flang/lib/FIR/statement.def deleted file mode 100644 index df43afc..0000000 --- a/flang/lib/FIR/statement.def +++ /dev/null @@ -1,172 +0,0 @@ -// Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef FIRST_TERM_STMT -#define FIRST_TERM_STMT(num) -#endif -#ifndef HANDLE_TERM_STMT -#ifndef HANDLE_STMT -#define HANDLE_TERM_STMT(num, opcode, Class) -#else -#define HANDLE_TERM_STMT(num, opcode, Class) HANDLE_STMT(num, opcode, Class) -#endif -#endif -#ifndef LAST_TERM_STMT -#define LAST_TERM_STMT(num) -#endif - -#ifndef FIRST_COMPUTE_STMT -#define FIRST_COMPUTE_STMT(num) -#endif -#ifndef HANDLE_COMPUTE_STMT -#ifndef HANDLE_STMT -#define HANDLE_COMPUTE_STMT(num, opcode, instclass) -#else -#define HANDLE_COMPUTE_STMT(num, opcode, Class) HANDLE_STMT(num, opcode, Class) -#endif -#endif -#ifndef LAST_COMPUTE_STMT -#define LAST_COMPUTE_STMT(num) -#endif - -#ifndef FIRST_MEMORY_STMT -#define FIRST_MEMORY_STMT(num) -#endif -#ifndef HANDLE_MEMORY_STMT -#ifndef HANDLE_STMT -#define HANDLE_MEMORY_STMT(num, opcode, Class) -#else -#define HANDLE_MEMORY_STMT(num, opcode, Class) HANDLE_STMT(num, opcode, Class) -#endif -#endif -#ifndef LAST_MEMORY_STMT -#define LAST_MEMORY_STMT(num) -#endif - -#ifndef FIRST_CAST_STMT -#define FIRST_CAST_STMT(num) -#endif -#ifndef HANDLE_CAST_STMT -#ifndef HANDLE_STMT -#define HANDLE_CAST_STMT(num, opcode, Class) -#else -#define HANDLE_CAST_STMT(num, opcode, Class) HANDLE_STMT(num, opcode, Class) -#endif -#endif -#ifndef LAST_CAST_STMT -#define LAST_CAST_STMT(num) -#endif - -#ifndef FIRST_OTHER_STMT -#define FIRST_OTHER_STMT(num) -#endif -#ifndef HANDLE_LAST_OTHER_STMT -#ifndef HANDLE_LAST_STMT -#ifndef HANDLE_OTHER_STMT -#ifndef HANDLE_STMT -#define HANDLE_LAST_OTHER_STMT(num, opcode, Class) -#else -#define HANDLE_LAST_OTHER_STMT(num, opcode, Class) \ - HANDLE_STMT(num, opcode, Class) -#endif -#else -#define HANDLE_LAST_OTHER_STMT(num, opcode, Class) \ - HANDLE_OTHER_STMT(num, opcode, Class) -#endif -#else -#define HANDLE_LAST_OTHER_STMT(num, opcode, Class) \ - HANDLE_LAST_STMT(num, opcode, Class) -#endif -#endif -#ifndef HANDLE_OTHER_STMT -#ifndef HANDLE_STMT -#define HANDLE_OTHER_STMT(num, opcode, Class) -#else -#define HANDLE_OTHER_STMT(num, opcode, Class) HANDLE_STMT(num, opcode, Class) -#endif -#endif -#ifndef LAST_OTHER_STMT -#define LAST_OTHER_STMT(num) -#endif - -// Terminator Instructions - These instructions are used to terminate a basic -// block of the program. Every basic block must end with one of these -// instructions for it to be a well formed basic block. -FIRST_TERM_STMT(1) -HANDLE_TERM_STMT( 1, Return, ReturnStmt) -HANDLE_TERM_STMT( 2, Branch, BranchStmt) -HANDLE_TERM_STMT( 3, Switch, SwitchStmt) -HANDLE_TERM_STMT( 4, SwitchCase, SwitchCaseStmt) -HANDLE_TERM_STMT( 5, SwitchType, SwitchTypeStmt) -HANDLE_TERM_STMT( 6, SwitchRank, SwitchRankStmt) -HANDLE_TERM_STMT( 7, IndirectBranch, IndirectBranchStmt) -HANDLE_TERM_STMT( 8, Unreachable, UnreachableStmt) -LAST_TERM_STMT(8) - -// Standard actions - These instructions capture computations as -// evaluate::expressions -FIRST_COMPUTE_STMT(9) -HANDLE_COMPUTE_STMT( 9, Assign, AssignmentStmt) -HANDLE_COMPUTE_STMT(10, PointerAssign, PointerAssignStmt) -HANDLE_COMPUTE_STMT(11, LabelAssign, LabelAssignStmt) -HANDLE_COMPUTE_STMT(12, ApplyExpr, ApplyExprStmt) -HANDLE_COMPUTE_STMT(13, LocateExpr, LocateExprStmt) -LAST_COMPUTE_STMT(13) - -// Memory operators - These instructions capture ALLOCATE and DEALLOCATE -// Fortran statements -FIRST_MEMORY_STMT(14) -HANDLE_MEMORY_STMT(14, Allocate, AllocateInsn) -HANDLE_MEMORY_STMT(15, Deallocate, DeallocateInsn) -HANDLE_MEMORY_STMT(16, AllocLocal, AllocateLocalInsn) -HANDLE_MEMORY_STMT(17, Load, LoadInsn) -HANDLE_MEMORY_STMT(18, Store, StoreInsn) -HANDLE_MEMORY_STMT(19, Disassociate, DisassociateInsn) -LAST_MEMORY_STMT(19) - -// Other operators - These are operations that don't fit the above categories -FIRST_OTHER_STMT(20) -HANDLE_OTHER_STMT(20, Call, CallStmt) -HANDLE_OTHER_STMT(21, RuntimeCall, RuntimeStmt) -HANDLE_OTHER_STMT(22, IORuntimeCall, IORuntimeStmt) -HANDLE_OTHER_STMT(23, ScopeEnter, ScopeEnterStmt) -HANDLE_OTHER_STMT(24, ScopeExit, ScopeExitStmt) -HANDLE_LAST_OTHER_STMT(25, Phi, PHIStmt) -LAST_OTHER_STMT(25) - -#undef FIRST_TERM_STMT -#undef HANDLE_TERM_STMT -#undef LAST_TERM_STMT - -#undef FIRST_COMPUTE_STMT -#undef HANDLE_COMPUTE_STMT -#undef LAST_COMPUTE_STMT - -#undef FIRST_MEMORY_STMT -#undef HANDLE_MEMORY_STMT -#undef LAST_MEMORY_STMT - -#undef FIRST_CAST_STMT -#undef HANDLE_CAST_STMT -#undef LAST_CAST_STMT - -#undef FIRST_OTHER_STMT -#undef HANDLE_OTHER_STMT -#undef HANDLE_LAST_OTHER_STMT -#undef HANDLE_LAST_STMT -#undef LAST_OTHER_STMT - -#ifdef HANDLE_STMT -#undef HANDLE_STMT -#endif diff --git a/flang/lib/FIR/statements.h b/flang/lib/FIR/statements.h index 19d6428..0d3d607 100644 --- a/flang/lib/FIR/statements.h +++ b/flang/lib/FIR/statements.h @@ -74,6 +74,7 @@ public: class Stmt_impl { public: using StatementTrait = std::true_type; + virtual ~Stmt_impl() {} }; // Every basic block must end in a terminator @@ -250,6 +251,8 @@ public: return IndirectBranchStmt{variable, potentialTargets}; } + Variable *variable() const { return variable_; } + private: explicit IndirectBranchStmt( Variable *variable, const TargetListType &potentialTargets) @@ -355,6 +358,9 @@ public: return AllocateInsn{type, alignment}; } + Type type() const { return type_; } + int alignment() const { return alignment_; } + private: explicit AllocateInsn(Type type, int alignment) : type_{type}, alignment_{alignment} {} @@ -366,13 +372,15 @@ private: // Deallocate storage (per DEALLOCATE) class DeallocateInsn : public MemoryStmt_impl { public: - static DeallocateInsn Create(const AllocateInsn *alloc) { + static DeallocateInsn Create(AllocateInsn *alloc) { return DeallocateInsn{alloc}; } + AllocateInsn *alloc() { return alloc_; } + private: - explicit DeallocateInsn(const AllocateInsn *alloc) : alloc_{alloc} {} - const AllocateInsn *alloc_; + explicit DeallocateInsn(AllocateInsn *alloc) : alloc_{alloc} {} + AllocateInsn *alloc_; }; // Allocate space for a temporary by its Type. The lifetime of the temporary @@ -387,6 +395,9 @@ public: return AllocateLocalInsn{type, alignment}; } + Type type() const { return type_; } + int alignment() const { return alignment_; } + private: explicit AllocateLocalInsn(Type type, int alignment, const Expression &expr) : Addressable_impl{expr}, type_{type}, alignment_{alignment} {} @@ -432,6 +443,9 @@ public: return DisassociateInsn{n}; } + // FIXME - remove parse tree reference + const parser::NullifyStmt *disassociate() { return disassociate_; } + private: DisassociateInsn(const parser::NullifyStmt *n) : disassociate_{n} {} const parser::NullifyStmt *disassociate_; @@ -477,6 +491,8 @@ public: return RuntimeStmt{call, std::move(argument)}; } + RuntimeCallType call() const { return call_; } + private: explicit RuntimeStmt(RuntimeCallType call, RuntimeCallArguments &&arguments) : CallStmt_impl{nullptr, nullptr, std::move(arguments)}, call_{call} {} @@ -493,6 +509,8 @@ public: return IORuntimeStmt{call, std::move(arguments)}; } + InputOutputCallType call() const { return call_; } + private: explicit IORuntimeStmt(InputOutputCallType call, IOCallArguments &&arguments) : CallStmt_impl{nullptr, nullptr, std::move(arguments)}, call_{call} {} diff --git a/flang/lib/FIR/stmt.h b/flang/lib/FIR/stmt.h deleted file mode 100644 index 21d5b0d..0000000 --- a/flang/lib/FIR/stmt.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef FORTRAN_FIR_STMT_H_ -#define FORTRAN_FIR_STMT_H_ - -#include "basicblock.h" -#include "mixin.h" -#include "statements.h" - -namespace Fortran::FIR { - -/// Sum type over all statement classes -class Statement : public SumTypeMixin>, - public ChildMixin, - public llvm::ilist_node { -public: - template - Statement(BasicBlock *p, A &&t) : SumTypeMixin{t}, ChildMixin{p} { - parent->insertBefore(this); - } - std::string dump() const; -}; - -inline std::list succ_list(BasicBlock &block) { - if (auto *terminator{block.terminator()}) { - return reinterpret_cast(&terminator->u) - ->succ_blocks(); - } - // CHECK(false && "block does not have terminator"); - return {}; -} -} - -#endif -- 2.7.4