summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/APFloat.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [APFloat] Fix checked error assert failuresEhud Katz2020-01-091-3/+2
| | | | | | | | | | | `APFLoat::convertFromString` returns `Expected` result, which must be "checked" if the LLVM_ENABLE_ABI_BREAKING_CHECKS preprocessor flag is set. To mark an `Expected` result as "checked" we must consume the `Error` within. In many cases, we are only interested in knowing if an error occured, without the need to examine the error info. This is achieved, easily, with the `errorToBool()` API.
* [APFloat] Fix out of scope usage of a pointer to local variableEhud Katz2020-01-071-3/+7
|
* [APFloat] Fix fusedMultiplyAdd when `this` equals to `Addend`Ehud Katz2020-01-071-9/+12
| | | | | | | | | | | | | Up until now, the arguments to `fusedMultiplyAdd` are passed by reference. We must save the `Addend` value on the beginning of the function, before we modify `this`, as they may be the same reference. To fix this, we now pass the `addend` parameter of `multiplySignificand` by value (instead of by-ref), and have a default value of zero. Fix PR44051. Differential Revision: https://reviews.llvm.org/D70422
* [APFloat] Fix compilation warningsEhud Katz2020-01-061-1/+3
|
* [APFloat] Add recoverable string parsing errors to APFloatEhud Katz2020-01-061-58/+95
| | | | | | Implementing the APFloat part in PR4745. Differential Revision: https://reviews.llvm.org/D69770
* [APFloat] Fix subtraction of subnormal numbersEhud Katz2019-11-221-7/+4
| | | | | | | | Fix incorrect determination of the bigger number out of the two subtracted, while subnormal numbers are involved. Fixes PR44010. Differential Revision: https://reviews.llvm.org/D69772
* [clang] Add storage for APValue in ConstantExprGauthier Harnisch2019-06-151-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: When using ConstantExpr we often need the result of the expression to be kept in the AST. Currently this is done on a by the node that needs the result and has been done multiple times for enumerator, for constexpr variables... . This patch adds to ConstantExpr the ability to store the result of evaluating the expression. no functional changes expected. Changes: - Add trailling object to ConstantExpr that can hold an APValue or an uint64_t. the uint64_t is here because most ConstantExpr yield integral values so there is an optimized layout for integral values. - Add basic* serialization support for the trailing result. - Move conversion functions from an enum to a fltSemantics from clang::FloatingLiteral to llvm::APFloatBase. this change is to make it usable for serializing APValues. - Add basic* Import support for the trailing result. - ConstantExpr created in CheckConvertedConstantExpression now stores the result in the ConstantExpr Node. - Adapt AST dump to print the result when present. basic* : None, Indeterminate, Int, Float, FixedPoint, ComplexInt, ComplexFloat, the result is not yet used anywhere but for -ast-dump. Reviewers: rsmith, martong, shafik Reviewed By: rsmith Subscribers: rnkovacs, hiraditya, dexonsmith, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D62399 llvm-svn: 363493
* [APFloat] APFloat::Storage::Storage - refix use after moveNick Desaulniers2019-06-071-1/+2
| | | | | | | | | | | | | | | | | | | | | | | Summary: Re-land r360675 after it was reverted in r360770. This was reported in: https://llvm.org/reports/scan-build/ Based on feedback in: https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190513/652286.html Reviewers: RKSimon, efriedma Reviewed By: RKSimon, efriedma Subscribers: eli.friedman, hiraditya, llvm-commits, srhines Tags: #llvm Differential Revision: https://reviews.llvm.org/D62767 llvm-svn: 362833
* Revert rL360675 : [APFloat] APFloat::Storage::Storage - fix use after moveSimon Pilgrim2019-05-151-3/+3
| | | | | | | | This was mentioned both in https://www.viva64.com/en/b/0629/ and by scan-build checks ........ There's concerns this may just introduce a use-after-free instead..... llvm-svn: 360770
* [APFloat] APFloat::Storage::Storage - fix use after moveSimon Pilgrim2019-05-141-3/+3
| | | | | | This was mentioned both in https://www.viva64.com/en/b/0629/ and by scan-build checks llvm-svn: 360675
* [MC] Fix floating-point literal lexing.Eli Friedman2019-03-281-1/+4
| | | | | | | | | | | | | | | | | | | | | This patch has three related fixes to improve float literal lexing: 1. Make AsmLexer::LexDigit handle floats without a decimal point more consistently. 2. Make AsmLexer::LexFloatLiteral print an error for floats which are apparently missing an "e". 3. Make APFloat::convertFromString use binutils-compatible exponent parsing. Together, this fixes some cases where a float would be incorrectly rejected, fixes some cases where the compiler would crash, and improves diagnostics in some cases. Patch by Brandon Jones. Differential Revision: https://reviews.llvm.org/D57321 llvm-svn: 357214
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Remove trailing spaceFangrui Song2018-07-301-1/+1
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338293
* [APFloat] Set losesInfo on no-op convertSven van Haastregt2018-05-111-1/+3
| | | | | | | | | | | | losesInfo would be left unset when no conversion needs to be done. A caller such as InstCombine's fitsInFPType would then branch on an uninitialized value. Caught using valgrind on an out-of-tree target. Differential Revision: https://reviews.llvm.org/D46645 llvm-svn: 332087
* APFloat/x87: Fix string conversion for "unnormal" values (pr35860)Pavel Labath2018-05-091-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Unnormal values are a feature of some very old x87 processors. We handle them correctly for the most part -- the only exception was an unnormal value whose significand happened to be zero. In this case the APFloat was still initialized as normal number (category = fcNormal), but a subsequent toString operation would assert because the math would produce nonsensical values for the zero significand. During review, it was decided that the correct way to fix this is to treat all unnormal values as NaNs (as that is what any >=386 processor will do). The issue was discovered because LLDB would crash when trying to print some "long double" values. Reviewers: skatkov, scanon, gottesmm Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D41868 llvm-svn: 331884
* IWYU for llvm-config.h in llvm, additions.Nico Weber2018-04-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See r331124 for how I made a list of files missing the include. I then ran this Python script: for f in open('filelist.txt'): f = f.strip() fl = open(f).readlines() found = False for i in xrange(len(fl)): p = '#include "llvm/' if not fl[i].startswith(p): continue if fl[i][len(p):] > 'Config': fl.insert(i, '#include "llvm/Config/llvm-config.h"\n') found = True break if not found: print 'not found', f else: open(f, 'w').write(''.join(fl)) and then looked through everything with `svn diff | diffstat -l | xargs -n 1000 gvim -p` and tried to fix include ordering and whatnot. No intended behavior change. llvm-svn: 331184
* Fix APFloat from string conversion for InfSerguei Katkov2017-12-191-2/+2
| | | | | | | | | | | | | | | | | | The method IEEEFloat::convertFromStringSpecials() does not recognize the "+Inf" and "-Inf" strings but these strings are printed for the double Infinities by the IEEEFloat::toString(). This patch adds the "+Inf" and "-Inf" strings to the list of recognized patterns in IEEEFloat::convertFromStringSpecials(). Re-landing after fix. Reviewers: sberg, bogner, majnemer, timshen, rnk, skatkov, gottesmm, bkramer, scanon, anna Reviewed By: anna Subscribers: mkazantsev, FlameTop, llvm-commits, reames, apilipenko Differential Revision: https://reviews.llvm.org/D38030 llvm-svn: 321054
* Fix APFloat mod signSerguei Katkov2017-11-011-0/+3
| | | | | | | | | | | | fmod specification requires the sign of the remainder is the same as numerator in case remainder is zero. Reviewers: gottesmm, scanon, arsenm, davide, craig.topper Reviewed By: scanon Subscribers: wdng, llvm-commits Differential Revision: https://reviews.llvm.org/D39225 llvm-svn: 317081
* Revert rL316156 due to failure on APFloatTest.fromToStringSpecialsMax Kazantsev2017-10-191-2/+2
| | | | llvm-svn: 316158
* Fix APFloat from string conversion for InfSerguei Katkov2017-10-191-2/+2
| | | | | | | | | | | | | | | | The method IEEEFloat::convertFromStringSpecials() does not recognize the "+Inf" and "-Inf" strings but these strings are printed for the double Infinities by the IEEEFloat::toString(). This patch adds the "+Inf" and "-Inf" strings to the list of recognized patterns in IEEEFloat::convertFromStringSpecials(). Reviewers: sberg, bogner, majnemer, timshen, rnk, skatkov, gottesmm, bkramer, scanon Reviewed By: skatkov Subscribers: apilipenko, reames, llvm-commits Differential Revision: https://reviews.llvm.org/D38030 llvm-svn: 316156
* Reverting r315590; it did not include changes for llvm-tblgen, which is ↵Aaron Ballman2017-10-151-1/+1
| | | | | | | | causing link errors for several people. Error LNK2019 unresolved external symbol "public: void __cdecl `anonymous namespace'::MatchableInfo::dump(void)const " (?dump@MatchableInfo@?A0xf4f1c304@@QEBAXXZ) referenced in function "public: void __cdecl `anonymous namespace'::AsmMatcherEmitter::run(class llvm::raw_ostream &)" (?run@AsmMatcherEmitter@?A0xf4f1c304@@QEAAXAEAVraw_ostream@llvm@@@Z) llvm-tblgen D:\llvm\2017\utils\TableGen\AsmMatcherEmitter.obj 1 llvm-svn: 315854
* [dump] Remove NDEBUG from test to enable dump methods [NFC]Don Hinton2017-10-121-1/+1
| | | | | | | | | | | | | | | Summary: Add LLVM_FORCE_ENABLE_DUMP cmake option, and use it along with LLVM_ENABLE_ASSERTIONS to set LLVM_ENABLE_DUMP. Remove NDEBUG and only use LLVM_ENABLE_DUMP to enable dump methods. Move definition of LLVM_ENABLE_DUMP from config.h to llvm-config.h so it'll be picked up by public headers. Differential Revision: https://reviews.llvm.org/D38406 llvm-svn: 315590
* [APFloat] Fix IsInteger() for DoubleAPFloat.Davide Italiano2017-08-211-4/+1
| | | | | | | | Previously, we would just assert instead. Differential Revision: https://reviews.llvm.org/D36961 llvm-svn: 311351
* [APFloat] Move the integerPartWidth constant into APFloatBase. Remove ↵Craig Topper2017-06-181-37/+30
| | | | | | integerPart typedef at file scope and just use the one in APFloatBase everywhere. NFC llvm-svn: 305652
* Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.Galina Kistanova2017-05-301-0/+2
| | | | llvm-svn: 304187
* [AsmWriter/APFloat] FP constant printing: Avoid usage of locale dependent ↵Serguei Katkov2017-04-211-8/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | snprinf This should fix the bug https://bugs.llvm.org/show_bug.cgi?id=12906 To print the FP constant AsmWriter does the following: 1) convert FP value to String (actually using snprintf function which is locale dependent). 2) Convert String back to FP Value 3) Compare original and got FP values. If they are not equal just dump as hex. The problem happens on the 2nd step when APFloat does not expect group delimiter or fraction delimiter other than period symbol and so on, which can be produced on the first step if LLVM library is used in an environment with corresponding locale set. To fix this issue the locale independent APFloat:toString function is used. However it prints FP values slightly differently than snprintf does. Specifically it suppress trailing zeros in significant, use capital E and so on. It results in 117 test failures during make check. To avoid this I've also updated APFloat.toString a bit to pass make check at least. Reviewers: sberg, bogner, majnemer, sanjoy, timshen, rnk Reviewed By: timshen, rnk Subscribers: rnk, llvm-commits Differential Revision: https://reviews.llvm.org/D32276 llvm-svn: 300943
* [APInt] Use lshrInPlace to replace lshr where possibleCraig Topper2017-04-181-1/+1
| | | | | | | | | | This patch uses lshrInPlace to replace code where the object that lshr is called on is being overwritten with the result. This adds an lshrInPlace(const APInt &) version as well. Differential Revision: https://reviews.llvm.org/D32155 llvm-svn: 300566
* [APInt] Add a public typedef for the internal type of APInt use it instead ↵Craig Topper2017-04-021-0/+4
| | | | | | | | | | | | | | | | of integerPart. Make APINT_BITS_PER_WORD and APINT_WORD_SIZE public. This patch is one step to attempt to unify the main APInt interface and the tc functions used by APFloat. This patch adds a WordType to APInt and uses that in all the tc functions. I've added temporary typedefs to APFloat to alias it to integerPart to keep the patch size down. I'll work on removing that in a future patch. In future patches I hope to reuse the tc functions to implement some of the main APInt functionality. I may remove APINT_ from BITS_PER_WORD and WORD_SIZE constants so that we don't have the repetitive APInt::APINT_ externally. Differential Revision: https://reviews.llvm.org/D31523 llvm-svn: 299341
* Fix APFloat mod (committing for simonbyrne)Stephen Canon2017-03-311-33/+9
| | | | | | | | The previous version was prone to intermediate rounding or overflow. Differential Revision: https://reviews.llvm.org/D29346 llvm-svn: 299256
* Use MutableArrayRef for APFloat::convertToIntegerSimon Pilgrim2017-03-201-29/+34
| | | | | | As discussed on D31074, use MutableArrayRef for destination integer buffers to help assert before stack overflows happen. llvm-svn: 298253
* Strip trailing whitespaceSimon Pilgrim2017-03-201-5/+5
| | | | llvm-svn: 298247
* Cleanup dump() functions.Matthias Braun2017-01-281-1/+3
| | | | | | | | | | | | | | | | | | We had various variants of defining dump() functions in LLVM. Normalize them (this should just consistently implement the things discussed in http://lists.llvm.org/pipermail/cfe-dev/2014-January/034323.html For reference: - Public headers should just declare the dump() method but not use LLVM_DUMP_METHOD or #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) - The definition of a dump method should look like this: #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void MyClass::dump() { // print stuff to dbgs()... } #endif llvm-svn: 293359
* [APFloat] Reduce some dispatch boilerplates. NFC.Tim Shen2017-01-271-5/+12
| | | | | | | | | | | | Summary: This is an attempt to reduce the verbose manual dispatching code in APFloat. This doesn't handle multiple dispatch on single discriminator (e.g. APFloat::add(const APFloat&)), nor handles multiple dispatch on multiple discriminators (e.g. APFloat::convert()). Reviewers: hfinkel, echristo, jlebar Subscribers: mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D29161 llvm-svn: 293255
* [APFloat] Fix comments. NFC.Tim Shen2017-01-261-28/+30
| | | | | | | | | | | | Summary: Fix comments in response to jlebar's comments in D27872. Reviewers: jlebar Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29109 llvm-svn: 293116
* [APFloat] Add PPCDoubleDouble multiplicationTim Shen2017-01-241-6/+83
| | | | | | | | | | Reviewers: echristo, hfinkel, kbarton, iteratee Subscribers: mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D28382 llvm-svn: 292860
* [APFloat] Switch from (PPCDoubleDoubleImpl, IEEEdouble) layout to ↵Tim Shen2017-01-231-79/+320
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (IEEEdouble, IEEEdouble) Summary: This patch changes the layout of DoubleAPFloat, and adjust all operations to do either: 1) (IEEEdouble, IEEEdouble) -> (uint64_t, uint64_t) -> PPCDoubleDoubleImpl, then run the old algorithm. 2) Do the right thing directly. 1) includes multiply, divide, remainder, mod, fusedMultiplyAdd, roundToIntegral, convertFromString, next, convertToInteger, convertFromAPInt, convertFromSignExtendedInteger, convertFromZeroExtendedInteger, convertToHexString, toString, getExactInverse. 2) includes makeZero, makeLargest, makeSmallest, makeSmallestNormalized, compare, bitwiseIsEqual, bitcastToAPInt, isDenormal, isSmallest, isLargest, isInteger, ilogb, scalbn, frexp, hash_value, Profile. I could split this into two patches, e.g. use 1) for all operatoins first, then incrementally change some of them to 2). I didn't do that, because 1) involves code that converts data between PPCDoubleDoubleImpl and (IEEEdouble, IEEEdouble) back and forth, and may pessimize the compiler. Instead, I find easy functions and use approach 2) for them directly. Next step is to implement move multiply and divide from 1) to 2). I don't have plans for other functions in 1). Differential Revision: https://reviews.llvm.org/D27872 llvm-svn: 292839
* [ADT] APFloatBase: Prevent collapsing semPPCDoubleDouble and semBogusMichal Gorny2017-01-031-2/+6
| | | | | | | | | | | | | | | | | | | Provide a distinct contents for semBogus and semPPCDoubleDouble in order to prevent compilers from collapsing them to a single memory address, while we heavily rely on every semantic having distinct address. This happens if insecure optimization collapsing identical values is enabled. As a result, APFloats of semBogus are indistinguishable from semPPCDoubleDouble -- and whenever the move constructor is used, the old value beings being incorrectly recognized as a semPPCDoubleDouble. Since the values in semPPCDoubleDouble are not used anywhere, we can easily solve this issue via altering the value of one of the fields and therefore ensuring that the collapse can not occur. Differential Revision: https://reviews.llvm.org/D28112 llvm-svn: 290896
* [APFloat] Remove 'else' after return. NFCTim Shen2016-12-211-13/+15
| | | | | | | | | | Reviewers: kbarton, iteratee, hfinkel, echristo Subscribers: mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D27934 llvm-svn: 290232
* Replace APFloatBase static fltSemantics data members with getter functionsStephan Bergmann2016-12-141-84/+106
| | | | | | | | | | | | | At least the plugin used by the LibreOffice build (<https://wiki.documentfoundation.org/Development/Clang_plugins>) indirectly uses those members (through inline functions in LLVM/Clang include files in turn using them), but they are not exported by utils/extract_symbols.py on Windows, and accessing data across DLL/EXE boundaries on Windows is generally problematic. Differential Revision: https://reviews.llvm.org/D26671 llvm-svn: 289647
* [APFloat] Implement PPCDoubleDouble add and subtract.Tim Shen2016-12-121-3/+207
| | | | | | | | | | | | Summary: I looked at libgcc's implementation (which is based on the paper, Software for Doubled-Precision Floating-Point Computations", by Seppo Linnainmaa, ACM TOMS vol 7 no 3, September 1981, pages 272-283.) and made it generic to arbitrary IEEE floats. Differential Revision: https://reviews.llvm.org/D26817 llvm-svn: 289472
* Fix memory leaks (coverity issues 1365586 & 1365591)Sylvestre Ledru2016-11-081-2/+6
| | | | | | | | | | Reviewers: hfinkel Subscribers: george.burgess.iv, malcolm.parsons, boris.ulasevich, llvm-commits Differential Revision: https://reviews.llvm.org/D26347 llvm-svn: 286223
* [APFloat] Make functions that produce APFloaat objects use correct semantics.Tim Shen2016-11-061-19/+37
| | | | | | | | | | | | | | | | | Summary: Fixes PR30869. In D25977 I meant to change all functions that care about lifetime. I changed constructors, factory functions, but I missed member/free functions that return new instances. This patch changes them. Reviewers: hfinkel, kbarton, echristo, joerg Subscribers: llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D26269 llvm-svn: 286060
* [APFloat] Remove the redundent function body of uninitialized ctor, which ↵Tim Shen2016-10-291-4/+1
| | | | | | should be done in r285468 llvm-svn: 285486
* [APFloat] Fix memory bugs revealed by MSanTim Shen2016-10-281-3/+8
| | | | | | | | | | Reviewers: eugenis, hfinkel, kbarton, iteratee, echristo Subscribers: mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D26102 llvm-svn: 285468
* Reapply r285351 "[APFloat] Add DoubleAPFloat mode to APFloat. NFC." withTim Shen2016-10-271-59/+115
| | | | | | a workaround for old clang. llvm-svn: 285358
* Revert "[APFloat] Add DoubleAPFloat mode to APFloat. NFC."Tim Shen2016-10-271-115/+59
| | | | | | This reverts r285351, since it breaks the build. llvm-svn: 285354
* [APFloat] Add DoubleAPFloat mode to APFloat. NFC.Tim Shen2016-10-271-59/+115
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch adds DoubleAPFloat mode to APFloat. Now, an APFloat with semantics PPCDoubleDouble will have DoubleAPFloat layout (APFloat.U.Double), which contains two underlying APFloats as PPCDoubleDoubleImpl and IEEEdouble semantics. Currently the IEEEdouble APFloat is not used, and the first APFloat behaves exactly the same before this change. This patch consists of three kinds of logics: 1) Construction and destruction of APFloat. Now the ctors, dtor, assign opertors and factory functions construct different underlying layout based on the semantics passed in. 2) s/IEEE/getIEEE()/ for normal, lifetime-unrelated computation functions. These functions only access Floats[0] in DoubleAPFloat, which is the same as today's semantic. 3) A "Double dispatch" function, APFloat::convert. Converting between two different layouts requires appropriate logic. Neither of these change the external behavior. Reviewers: hfinkel, kbarton, echristo, iteratee Subscribers: mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D25977 llvm-svn: 285351
* [APFloat] Make APFloat an interface class to the internal IEEEFloat. NFC.Tim Shen2016-10-251-372/+244
| | | | | | | | | | | | | | | | | | | | | Summary: The intention is to make APFloat an interface class, so that later I can add a second implementation class DoubleAPFloat to correctly implement PPCDoubleDouble semantic. The interface of IEEEFloat is not public, and can be simplified (currently it's exactly the same as the old APFloat), but that belongs to a separate patch. DoubleAPFloat should look like: class DoubleAPFloat { const fltSemantics *Semantics; std::unique_ptr<APFloat> APFloats; // Two heap-allocated APFloats. }; There is no functional change, nor public interface change. Reviewers: hfinkel, chandlerc, iteratee, echristo, kbarton Subscribers: llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D25536 llvm-svn: 285105
* Remove some unneeded headers and replace some headers with forward class ↵Mehdi Amini2016-04-161-0/+1
| | | | | | | | | | | declarations (NFC) Differential Revision: http://reviews.llvm.org/D19154 Patch by Eugene Kosov <claprix@yandex.ru> From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266524
* Revert "Fix Clang-tidy modernize-deprecated-headers warnings in remaining ↵Duncan P. N. Exon Smith2016-04-051-44/+30
| | | | | | | | | | files; other minor fixes." This reverts commit r265454 since it broke the build. E.g.: http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_build/22413/ llvm-svn: 265459
OpenPOWER on IntegriCloud