blob: 983eed76ef38849b380a18783b7d87d1bc6fb28b [file] [log] [blame]
Chris Lattner6b944532002-10-28 01:16:38 +00001//===-- MachineFunction.cpp -----------------------------------------------===//
Chris Lattnerf2868ce2002-02-03 07:54:50 +00002//
John Criswellb576c942003-10-20 19:43:21 +00003// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
Chris Lattner6b944532002-10-28 01:16:38 +000010// Collect native machine code information for a function. This allows
11// target-specific information about the generated code to be stored with each
12// function.
13//
14//===----------------------------------------------------------------------===//
Chris Lattnerf2868ce2002-02-03 07:54:50 +000015
Chris Lattner16c45e92003-12-20 10:20:58 +000016#include "llvm/CodeGen/MachineFunctionPass.h"
Chris Lattner831fdcf2002-12-25 05:03:22 +000017#include "llvm/CodeGen/MachineInstr.h"
Chris Lattner831fdcf2002-12-25 05:03:22 +000018#include "llvm/CodeGen/SSARegMap.h"
Chris Lattner955fad12002-12-28 20:37:16 +000019#include "llvm/CodeGen/MachineFunctionInfo.h"
Chris Lattnereb24db92002-12-28 21:08:26 +000020#include "llvm/CodeGen/MachineFrameInfo.h"
Chris Lattner4d149cd2003-01-13 00:23:03 +000021#include "llvm/CodeGen/MachineConstantPool.h"
Chris Lattner16c45e92003-12-20 10:20:58 +000022#include "llvm/CodeGen/Passes.h"
Chris Lattnerf2868ce2002-02-03 07:54:50 +000023#include "llvm/Target/TargetMachine.h"
Chris Lattner8bd66e62002-12-28 21:00:25 +000024#include "llvm/Target/TargetFrameInfo.h"
Chris Lattnerf27eeea2002-12-29 02:50:35 +000025#include "llvm/Target/TargetCacheInfo.h"
Chris Lattner2fbfdcf2002-04-07 20:49:59 +000026#include "llvm/Function.h"
Chris Lattnerf2868ce2002-02-03 07:54:50 +000027#include "llvm/iOther.h"
Chris Lattner07f32d42003-12-20 09:17:07 +000028using namespace llvm;
Chris Lattnerf2868ce2002-02-03 07:54:50 +000029
Chris Lattnere316efc2002-10-29 23:18:43 +000030static AnnotationID MF_AID(
Chris Lattner2fbfdcf2002-04-07 20:49:59 +000031 AnnotationManager::getID("CodeGen::MachineCodeForFunction"));
Chris Lattnerf2868ce2002-02-03 07:54:50 +000032
Chris Lattner227c3d32002-10-28 01:12:41 +000033
Chris Lattner227c3d32002-10-28 01:12:41 +000034namespace {
Chris Lattner16c45e92003-12-20 10:20:58 +000035 struct Printer : public MachineFunctionPass {
Brian Gaeke09caa372004-01-30 21:53:46 +000036 std::ostream *OS;
Chris Lattnerd4baf0f2004-02-01 05:25:07 +000037 const std::string Banner;
Brian Gaeke09caa372004-01-30 21:53:46 +000038
39 Printer (std::ostream *_OS, const std::string &_Banner) :
40 OS (_OS), Banner (_Banner) { }
41
Chris Lattner10491642002-10-30 00:48:05 +000042 const char *getPassName() const { return "MachineFunction Printer"; }
43
44 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
45 AU.setPreservesAll();
46 }
47
Chris Lattner16c45e92003-12-20 10:20:58 +000048 bool runOnMachineFunction(MachineFunction &MF) {
Brian Gaeke09caa372004-01-30 21:53:46 +000049 (*OS) << Banner;
50 MF.print (*OS);
Chris Lattner10491642002-10-30 00:48:05 +000051 return false;
52 }
53 };
Chris Lattner227c3d32002-10-28 01:12:41 +000054}
55
Brian Gaeke09caa372004-01-30 21:53:46 +000056/// Returns a newly-created MachineFunction Printer pass. The default output
57/// stream is std::cerr; the default banner is empty.
58///
59FunctionPass *llvm::createMachineFunctionPrinterPass(std::ostream *OS,
60 const std::string &Banner) {
61 return new Printer(OS, Banner);
Chris Lattner10491642002-10-30 00:48:05 +000062}
63
Alkis Evlogimenosc81efdc2004-02-15 00:03:15 +000064namespace {
65 struct Deleter : public MachineFunctionPass {
66 const char *getPassName() const { return "Machine Code Deleter"; }
67
68 bool runOnMachineFunction(MachineFunction &MF) {
69 // Delete the annotation from the function now.
70 MachineFunction::destruct(MF.getFunction());
71 return true;
72 }
73 };
74}
75
76/// MachineCodeDeletion Pass - This pass deletes all of the machine code for
77/// the current function, which should happen after the function has been
78/// emitted to a .s file or to memory.
79FunctionPass *llvm::createMachineCodeDeleter() {
80 return new Deleter();
81}
82
83
84
Chris Lattner227c3d32002-10-28 01:12:41 +000085//===---------------------------------------------------------------------===//
86// MachineFunction implementation
87//===---------------------------------------------------------------------===//
88
Chris Lattner10491642002-10-30 00:48:05 +000089MachineFunction::MachineFunction(const Function *F,
Chris Lattner955fad12002-12-28 20:37:16 +000090 const TargetMachine &TM)
91 : Annotation(MF_AID), Fn(F), Target(TM) {
Misha Brukmanb7825bc2002-11-20 18:55:27 +000092 SSARegMapping = new SSARegMap();
Chris Lattner955fad12002-12-28 20:37:16 +000093 MFInfo = new MachineFunctionInfo(*this);
Chris Lattnereb24db92002-12-28 21:08:26 +000094 FrameInfo = new MachineFrameInfo();
Chris Lattner4d149cd2003-01-13 00:23:03 +000095 ConstantPool = new MachineConstantPool();
Chris Lattner831fdcf2002-12-25 05:03:22 +000096}
97
98MachineFunction::~MachineFunction() {
99 delete SSARegMapping;
Chris Lattner955fad12002-12-28 20:37:16 +0000100 delete MFInfo;
101 delete FrameInfo;
Chris Lattner4d149cd2003-01-13 00:23:03 +0000102 delete ConstantPool;
Chris Lattner10491642002-10-30 00:48:05 +0000103}
104
105void MachineFunction::dump() const { print(std::cerr); }
106
107void MachineFunction::print(std::ostream &OS) const {
Chris Lattner955fad12002-12-28 20:37:16 +0000108 OS << "\n" << *(Value*)Fn->getFunctionType() << " \"" << Fn->getName()
109 << "\"\n";
110
111 // Print Frame Information
Chris Lattner9085d8a2003-01-16 18:35:57 +0000112 getFrameInfo()->print(*this, OS);
Chris Lattner4d149cd2003-01-13 00:23:03 +0000113
114 // Print Constant Pool
115 getConstantPool()->print(OS);
Chris Lattner10491642002-10-30 00:48:05 +0000116
Brian Gaeke90421cd2004-02-13 04:39:55 +0000117 for (const_iterator BB = begin(); BB != end(); ++BB)
118 BB->print(OS);
Chris Lattner10491642002-10-30 00:48:05 +0000119 OS << "\nEnd function \"" << Fn->getName() << "\"\n\n";
120}
121
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000122// The next two methods are used to construct and to retrieve
Chris Lattner2fbfdcf2002-04-07 20:49:59 +0000123// the MachineCodeForFunction object for the given function.
124// construct() -- Allocates and initializes for a given function and target
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000125// get() -- Returns a handle to the object.
126// This should not be called before "construct()"
Chris Lattner2fbfdcf2002-04-07 20:49:59 +0000127// for a given Function.
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000128//
Misha Brukmanfce11432002-10-28 00:28:31 +0000129MachineFunction&
Chris Lattner335d5c32002-10-28 05:58:46 +0000130MachineFunction::construct(const Function *Fn, const TargetMachine &Tar)
Vikram S. Adve89e2da02002-03-18 03:36:30 +0000131{
Chris Lattnere316efc2002-10-29 23:18:43 +0000132 assert(Fn->getAnnotation(MF_AID) == 0 &&
Chris Lattner2fbfdcf2002-04-07 20:49:59 +0000133 "Object already exists for this function!");
Chris Lattner335d5c32002-10-28 05:58:46 +0000134 MachineFunction* mcInfo = new MachineFunction(Fn, Tar);
135 Fn->addAnnotation(mcInfo);
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000136 return *mcInfo;
137}
138
Chris Lattner16c45e92003-12-20 10:20:58 +0000139void MachineFunction::destruct(const Function *Fn) {
Chris Lattnere316efc2002-10-29 23:18:43 +0000140 bool Deleted = Fn->deleteAnnotation(MF_AID);
Chris Lattner2fbfdcf2002-04-07 20:49:59 +0000141 assert(Deleted && "Machine code did not exist for function!");
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000142}
143
Chris Lattner335d5c32002-10-28 05:58:46 +0000144MachineFunction& MachineFunction::get(const Function *F)
Vikram S. Adve89e2da02002-03-18 03:36:30 +0000145{
Chris Lattnere316efc2002-10-29 23:18:43 +0000146 MachineFunction *mc = (MachineFunction*)F->getAnnotation(MF_AID);
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000147 assert(mc && "Call construct() method first to allocate the object");
148 return *mc;
149}
150
Chris Lattner831fdcf2002-12-25 05:03:22 +0000151void MachineFunction::clearSSARegMap() {
152 delete SSARegMapping;
153 SSARegMapping = 0;
154}
155
Chris Lattner955fad12002-12-28 20:37:16 +0000156//===----------------------------------------------------------------------===//
Chris Lattnereb24db92002-12-28 21:08:26 +0000157// MachineFrameInfo implementation
Chris Lattner955fad12002-12-28 20:37:16 +0000158//===----------------------------------------------------------------------===//
159
Chris Lattner4d149cd2003-01-13 00:23:03 +0000160/// CreateStackObject - Create a stack object for a value of the specified type.
161///
162int MachineFrameInfo::CreateStackObject(const Type *Ty, const TargetData &TD) {
163 return CreateStackObject(TD.getTypeSize(Ty), TD.getTypeAlignment(Ty));
164}
165
166int MachineFrameInfo::CreateStackObject(const TargetRegisterClass *RC) {
167 return CreateStackObject(RC->getSize(), RC->getAlignment());
168}
169
170
Chris Lattner9085d8a2003-01-16 18:35:57 +0000171void MachineFrameInfo::print(const MachineFunction &MF, std::ostream &OS) const{
172 int ValOffset = MF.getTarget().getFrameInfo().getOffsetOfLocalArea();
173
Chris Lattner955fad12002-12-28 20:37:16 +0000174 for (unsigned i = 0, e = Objects.size(); i != e; ++i) {
175 const StackObject &SO = Objects[i];
Chris Lattner4d149cd2003-01-13 00:23:03 +0000176 OS << " <fi #" << (int)(i-NumFixedObjects) << "> is ";
Chris Lattner955fad12002-12-28 20:37:16 +0000177 if (SO.Size == 0)
178 OS << "variable sized";
179 else
180 OS << SO.Size << " byte" << (SO.Size != 1 ? "s" : " ");
181
182 if (i < NumFixedObjects)
183 OS << " fixed";
184 if (i < NumFixedObjects || SO.SPOffset != -1) {
Chris Lattner9085d8a2003-01-16 18:35:57 +0000185 int Off = SO.SPOffset + ValOffset;
Chris Lattner955fad12002-12-28 20:37:16 +0000186 OS << " at location [SP";
Chris Lattner9085d8a2003-01-16 18:35:57 +0000187 if (Off > 0)
188 OS << "+" << Off;
189 else if (Off < 0)
190 OS << Off;
Chris Lattner955fad12002-12-28 20:37:16 +0000191 OS << "]";
192 }
193 OS << "\n";
194 }
195
196 if (HasVarSizedObjects)
197 OS << " Stack frame contains variable sized objects\n";
198}
199
Chris Lattner9085d8a2003-01-16 18:35:57 +0000200void MachineFrameInfo::dump(const MachineFunction &MF) const {
201 print(MF, std::cerr);
202}
Chris Lattner955fad12002-12-28 20:37:16 +0000203
204
205//===----------------------------------------------------------------------===//
Chris Lattner4d149cd2003-01-13 00:23:03 +0000206// MachineConstantPool implementation
207//===----------------------------------------------------------------------===//
208
209void MachineConstantPool::print(std::ostream &OS) const {
210 for (unsigned i = 0, e = Constants.size(); i != e; ++i)
211 OS << " <cp #" << i << "> is" << *(Value*)Constants[i] << "\n";
212}
213
214void MachineConstantPool::dump() const { print(std::cerr); }
215
216//===----------------------------------------------------------------------===//
Chris Lattner955fad12002-12-28 20:37:16 +0000217// MachineFunctionInfo implementation
218//===----------------------------------------------------------------------===//
Chris Lattner831fdcf2002-12-25 05:03:22 +0000219
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000220static unsigned
Vikram S. Adve03d33bd2002-04-25 04:30:43 +0000221ComputeMaxOptionalArgsSize(const TargetMachine& target, const Function *F,
222 unsigned &maxOptionalNumArgs)
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000223{
Chris Lattner955fad12002-12-28 20:37:16 +0000224 const TargetFrameInfo &frameInfo = target.getFrameInfo();
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000225
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000226 unsigned maxSize = 0;
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000227
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000228 for (Function::const_iterator BB = F->begin(), BBE = F->end(); BB !=BBE; ++BB)
229 for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I)
Chris Lattner2ee82e02003-04-23 16:36:11 +0000230 if (const CallInst *callInst = dyn_cast<CallInst>(I))
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000231 {
232 unsigned numOperands = callInst->getNumOperands() - 1;
233 int numExtra = (int)numOperands-frameInfo.getNumFixedOutgoingArgs();
234 if (numExtra <= 0)
235 continue;
236
Chris Lattner955fad12002-12-28 20:37:16 +0000237 unsigned sizeForThisCall;
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000238 if (frameInfo.argsOnStackHaveFixedSize())
239 {
240 int argSize = frameInfo.getSizeOfEachArgOnStack();
241 sizeForThisCall = numExtra * (unsigned) argSize;
242 }
243 else
244 {
245 assert(0 && "UNTESTED CODE: Size per stack argument is not "
246 "fixed on this architecture: use actual arg sizes to "
247 "compute MaxOptionalArgsSize");
248 sizeForThisCall = 0;
249 for (unsigned i = 0; i < numOperands; ++i)
Chris Lattner955fad12002-12-28 20:37:16 +0000250 sizeForThisCall += target.getTargetData().getTypeSize(callInst->
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000251 getOperand(i)->getType());
252 }
253
254 if (maxSize < sizeForThisCall)
255 maxSize = sizeForThisCall;
256
257 if ((int)maxOptionalNumArgs < numExtra)
258 maxOptionalNumArgs = (unsigned) numExtra;
259 }
Vikram S. Adve89e2da02002-03-18 03:36:30 +0000260
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000261 return maxSize;
262}
263
264// Align data larger than one L1 cache line on L1 cache line boundaries.
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000265// Align all smaller data on the next higher 2^x boundary (4, 8, ...),
266// but not higher than the alignment of the largest type we support
267// (currently a double word). -- see class TargetData).
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000268//
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000269// This function is similar to the corresponding function in EmitAssembly.cpp
270// but they are unrelated. This one does not align at more than a
271// double-word boundary whereas that one might.
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000272//
Chris Lattner955fad12002-12-28 20:37:16 +0000273inline unsigned
274SizeToAlignment(unsigned size, const TargetMachine& target)
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000275{
276 unsigned short cacheLineSize = target.getCacheInfo().getCacheLineSize(1);
277 if (size > (unsigned) cacheLineSize / 2)
278 return cacheLineSize;
279 else
280 for (unsigned sz=1; /*no condition*/; sz *= 2)
Chris Lattner955fad12002-12-28 20:37:16 +0000281 if (sz >= size || sz >= target.getTargetData().getDoubleAlignment())
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000282 return sz;
283}
284
285
Chris Lattner955fad12002-12-28 20:37:16 +0000286void MachineFunctionInfo::CalculateArgSize() {
287 maxOptionalArgsSize = ComputeMaxOptionalArgsSize(MF.getTarget(),
288 MF.getFunction(),
Vikram S. Adve03d33bd2002-04-25 04:30:43 +0000289 maxOptionalNumArgs);
Vikram S. Adve89e2da02002-03-18 03:36:30 +0000290 staticStackSize = maxOptionalArgsSize
Chris Lattner955fad12002-12-28 20:37:16 +0000291 + MF.getTarget().getFrameInfo().getMinStackFrameSize();
Vikram S. Adve89e2da02002-03-18 03:36:30 +0000292}
293
294int
Chris Lattner955fad12002-12-28 20:37:16 +0000295MachineFunctionInfo::computeOffsetforLocalVar(const Value* val,
296 unsigned &getPaddedSize,
297 unsigned sizeToUse)
Vikram S. Adve89e2da02002-03-18 03:36:30 +0000298{
Vikram S. Advee4e4d4e2002-03-24 03:39:26 +0000299 if (sizeToUse == 0)
Chris Lattner955fad12002-12-28 20:37:16 +0000300 sizeToUse = MF.getTarget().findOptimalStorageSize(val->getType());
301 unsigned align = SizeToAlignment(sizeToUse, MF.getTarget());
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000302
303 bool growUp;
Chris Lattner955fad12002-12-28 20:37:16 +0000304 int firstOffset = MF.getTarget().getFrameInfo().getFirstAutomaticVarOffset(MF,
305 growUp);
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000306 int offset = growUp? firstOffset + getAutomaticVarsSize()
307 : firstOffset - (getAutomaticVarsSize() + sizeToUse);
308
Chris Lattner955fad12002-12-28 20:37:16 +0000309 int aligned = MF.getTarget().getFrameInfo().adjustAlignment(offset, growUp, align);
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000310 getPaddedSize = sizeToUse + abs(aligned - offset);
311
312 return aligned;
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000313}
314
Chris Lattner07f32d42003-12-20 09:17:07 +0000315
316int MachineFunctionInfo::allocateLocalVar(const Value* val,
317 unsigned sizeToUse) {
Vikram S. Adve03d33bd2002-04-25 04:30:43 +0000318 assert(! automaticVarsAreaFrozen &&
319 "Size of auto vars area has been used to compute an offset so "
320 "no more automatic vars should be allocated!");
321
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000322 // Check if we've allocated a stack slot for this value already
323 //
Chris Lattner07f32d42003-12-20 09:17:07 +0000324 hash_map<const Value*, int>::const_iterator pair = offsets.find(val);
325 if (pair != offsets.end())
326 return pair->second;
327
328 unsigned getPaddedSize;
329 unsigned offset = computeOffsetforLocalVar(val, getPaddedSize, sizeToUse);
330 offsets[val] = offset;
331 incrementAutomaticVarsSize(getPaddedSize);
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000332 return offset;
333}
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000334
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000335int
Chris Lattner955fad12002-12-28 20:37:16 +0000336MachineFunctionInfo::allocateSpilledValue(const Type* type)
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000337{
Vikram S. Adve03d33bd2002-04-25 04:30:43 +0000338 assert(! spillsAreaFrozen &&
339 "Size of reg spills area has been used to compute an offset so "
340 "no more register spill slots should be allocated!");
341
Chris Lattner955fad12002-12-28 20:37:16 +0000342 unsigned size = MF.getTarget().getTargetData().getTypeSize(type);
343 unsigned char align = MF.getTarget().getTargetData().getTypeAlignment(type);
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000344
345 bool growUp;
Chris Lattner955fad12002-12-28 20:37:16 +0000346 int firstOffset = MF.getTarget().getFrameInfo().getRegSpillAreaOffset(MF, growUp);
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000347
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000348 int offset = growUp? firstOffset + getRegSpillsSize()
349 : firstOffset - (getRegSpillsSize() + size);
350
Chris Lattner955fad12002-12-28 20:37:16 +0000351 int aligned = MF.getTarget().getFrameInfo().adjustAlignment(offset, growUp, align);
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000352 size += abs(aligned - offset); // include alignment padding in size
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000353
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000354 incrementRegSpillsSize(size); // update size of reg. spills area
355
356 return aligned;
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000357}
358
359int
Chris Lattner955fad12002-12-28 20:37:16 +0000360MachineFunctionInfo::pushTempValue(unsigned size)
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000361{
Chris Lattner955fad12002-12-28 20:37:16 +0000362 unsigned align = SizeToAlignment(size, MF.getTarget());
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000363
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000364 bool growUp;
Chris Lattner955fad12002-12-28 20:37:16 +0000365 int firstOffset = MF.getTarget().getFrameInfo().getTmpAreaOffset(MF, growUp);
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000366
367 int offset = growUp? firstOffset + currentTmpValuesSize
368 : firstOffset - (currentTmpValuesSize + size);
369
Chris Lattner955fad12002-12-28 20:37:16 +0000370 int aligned = MF.getTarget().getFrameInfo().adjustAlignment(offset, growUp,
371 align);
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000372 size += abs(aligned - offset); // include alignment padding in size
373
374 incrementTmpAreaSize(size); // update "current" size of tmp area
375
376 return aligned;
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000377}
378
Chris Lattner955fad12002-12-28 20:37:16 +0000379void MachineFunctionInfo::popAllTempValues() {
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000380 resetTmpAreaSize(); // clear tmp area to reuse
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000381}
382